Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rotation Limiter?

Status
Not open for further replies.

abbott567

Technical User
Jun 18, 2007
38
GB
hey-
i am using the code

a1 = eye._y-_ymouse;
b1 = eye._x-_xmouse;
angleA1 = Math.atan2(a1, b1);
degrees1 = angleA1/(Math.PI/180);
setProperty ("eye", _rotation, degrees1);

and this makes my eye follow the mouse through 360 degrees and works fine.

however - on a different page unrelated to this one...
is there a way i can set a limiter on the angle so that it will only rotate through maybe 90

i want to have my character point to a board when u scroll down each menu button on the board - i literally want his hand to point from the top of the board to the bottom as you move down it but i dont want his hand to follow the cursor unless the pointer is actually over the menu selections on the board - if you get me...

i can only get his arm to do complete rotations which looks stupid when you have the mouse behind him

thanks in advance
 
setProperty" is Flash 4 - what version of Flash are you using?

Anyway, you can use "if" statement:
[tt]
if(angleA1 > Math.PI*5/8 && angleA1 < Math.PI*7/8){
eye._rotation = angleA1*180/Math.PI;
}
[/tt]

Kenneth Kawamoto
 
im using flash 8 lol
im not very fluent in flash coding!

that if function works - however as ive never seen it done i am unsure exactly how to set my angles

what is the 5/8 and the 7/8 - ive sussed if i play around with these i can change the angle it moves through - however i want it to go from about 2oclock to about 4 oclock and i cant seem to figure it out

thanks for any help!
 
Sorry Math.PI*5/8 and Math.PI*7/8 were just examples - I didn't know exactly what angles you were talking about :)

Try Math.PI/4 and -Math.PI/4 - these are more like angles you want.

Kenneth Kawamoto
 
Still cant get 2 and 4 oclock lol
it dont actually understand what is going on - im just punching in numbers and hoping it will work - but to no avail

i can get from 12 oclock to 3oclock (which is as close as i can get) using

a1 = eye._y-_ymouse;
b1 = eye._x-_xmouse;
angleA1 = Math.atan2(a1, b1);
degrees1 = angleA1/(Math.PI/180);
if(angleA1 > Math.PI/2 && angleA1 < Math.PI/1){
eye._rotation = angleA1*180/Math.PI;
}

 
your a legend mate!
thank you so much!

i wish i could understand WHY that code works
however right now im not that bothered so long as it does haha

many many thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top