Alice Community make a turn limit

 make a turn limit
 dakota95 Senior Member     Status: Offline Posts: 426 Join Date: Aug 2011 Location: like I would tell you. ;) make a turn limit - 12-19-2011, 01:44 PM How to I limit how much something can turn? 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????
 TauTrumpsPi Senior Member     Status: Offline Posts: 399 Join Date: Mar 2011 Location: The diamond layer 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 -------------------------------------------------------------------------------------------------------------------------- I have plenty of common sense. I just choose to ignore it. -Calvin and Hobbes Wondering about my Avatar? http://en.wikipedia.org/wiki/Tardigrade Wondering about my username? http://www.youtube.com/watch?v=jG7vhMMXagQ
dakota95
Senior Member

Status: Offline
Posts: 426
Join Date: Aug 2011
Location: like I would tell you. ;)
12-20-2011, 10:47 AM

Quote:
 Originally Posted by TauTrumpsPi In your turn method, have a variable go up as it turns. If (variable) is below/above a certain point, stop the turning object
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?

<Insert_Signature_Here>

 Joker899 Junior Member   Status: Offline Posts: 5 Join Date: Dec 2011 Location: Canada 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 Senior Member   Status: Offline Posts: 442 Join Date: Feb 2011 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
Senior Member

Status: Offline
Posts: 426
Join Date: Aug 2011
Location: like I would tell you. ;)
12-21-2011, 09:25 PM

Quote:
 Originally Posted by Mr Kidnapper 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.
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?

<Insert_Signature_Here>

TauTrumpsPi
Senior Member

Status: Offline
Posts: 399
Join Date: Mar 2011
Location: The diamond layer
12-22-2011, 08:25 AM

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
Attached Files
 StopTurn.a2w (638.0 KB, 2 views)

--------------------------------------------------------------------------------------------------------------------------
I have plenty of common sense. I just choose to ignore it.
-Calvin and Hobbes

dakota95
Senior Member

Status: Offline
Posts: 426
Join Date: Aug 2011
Location: like I would tell you. ;)
12-22-2011, 07:50 PM

Quote:
 Originally Posted by TauTrumpsPi 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
I'll check it out.

<Insert_Signature_Here>

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     Community News and Announcements Alice 3     How Do I?     Works In Progress     Share Your World     Share Custom Classes     Bugs and Trouble Shooting     Suggestion Box Alice 2     How do I...?     Works-In-Progress     Share Worlds     Share Objects     Bugs and Troubleshooting     Suggestion Box Educators     Teaching with Alice     Teaching Using Alice 3     Teaching Using Alice 2     CS Principles and Alice     AP CSA and Intro to Java and Alice     Workshops General Discussion     Questions and Comments     The Lounge