MaxManning
01-21-2008, 11:40 AM
I have a character that I am having follow a circle using Math.cos and Math.sin
I also want to rotate the character so his facing is correct each frame. I am saving the last x,y location and getting the angle between it and the new location to determine the facing
I am using this code :
_facing = Math.atan2(last_y-loc_y,last_x -loc_x)
rotation =( _facing / Math.PI * 180) - 180
note -- the -180 is for offsetting the default angle of the movieclip.
Which actually works.... EXCEPT for some reason every once in awhile that calculation completely flips my rotation for one frame?!!?
Make sense to anyone ?
I also want to rotate the character so his facing is correct each frame. I am saving the last x,y location and getting the angle between it and the new location to determine the facing
I am using this code :
_facing = Math.atan2(last_y-loc_y,last_x -loc_x)
rotation =( _facing / Math.PI * 180) - 180
note -- the -180 is for offsetting the default angle of the movieclip.
Which actually works.... EXCEPT for some reason every once in awhile that calculation completely flips my rotation for one frame?!!?
Make sense to anyone ?