Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   make a turn limit (http://www.alice.org/community/showthread.php?t=7842)

dakota95 12-19-2011 01:44 PM

make a turn limit
 
How to I limit how much something can turn?:confused:

for instance: that B-17 that mr kidnapper made, I am trying to make a game out of it. Only problem, when I turn the guns, they go right through the fuselage(body). What I need is a way to limit how far the guns can turn.

any ideas?:confused:?:confused:?:confused:?

TauTrumpsPi 12-19-2011 05:55 PM

In your turn method, have a variable go up as it turns.

If (variable) is below/above a certain point, stop the turning object

dakota95 12-20-2011 10:47 AM

[QUOTE=TauTrumpsPi;44916]In your turn method, have a variable go up as it turns.

If (variable) is below/above a certain point, stop the turning object[/QUOTE]

what if it is a gun on a moving airplane? Should I put a dummy where I want the limit? And what about a limit for sideways?

Joker899 12-20-2011 09:38 PM

Have a variable for each direction that it turns. Have an if/else that says
if [variable >= (value)]
do nothing
Else
Do together {
turn
increment variable by 1
}

Mr Kidnapper 12-20-2011 10:49 PM

You don't need a dummy object. What you need is a variable for each axis that is intended to rotate, so at most 3 axes. Set each of these to 0. Now, how fast is your rate of rotation? Say it's 5 per second. Let's make the rotation method
"If hAxis < 45
then gun turn right 5/360 rotations
hAxis = hAxis + 5
else do nothing
if hAxis >-45
then gun turn left 5/360 rotations
hAxis = hAxis - 5
else do nothing"
Turns in either direction 45 at most.

dakota95 12-21-2011 09:25 PM

[QUOTE=Mr Kidnapper;44972]You don't need a dummy object. What you need is a variable for each axis that is intended to rotate, so at most 3 axes. Set each of these to 0. Now, how fast is your rate of rotation? Say it's 5 per second. Let's make the rotation method
"If hAxis < 45
then gun turn right 5/360 rotations
hAxis = hAxis + 5
else do nothing
if hAxis >-45
then gun turn left 5/360 rotations
hAxis = hAxis - 5
else do nothing"
Turns in either direction 45 at most.[/QUOTE]

Gosh. Guess I should learn how to use variables at some point. I just tried to get along without 'em. Can you give me a step-by-step and write out exactly what I need to do, where to find the correct stuff, and anything else I might need to know?

TauTrumpsPi 12-22-2011 08:25 AM

1 Attachment(s)
Get along without variables!? How!?

Anyway, here's an example of how to stop a turn. It uses variables though, so you might need to learn those

dakota95 12-22-2011 07:50 PM

[QUOTE=TauTrumpsPi;45009]Get along without variables!? How!?

Anyway, here's an example of how to stop a turn. It uses variables though, so you might need to learn those[/QUOTE]

I'll check it out.


All times are GMT -5. The time now is 10:43 PM.

Copyright ©2019, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.