If I have a player character that can move 8-directionally, I can set the rotation of the player to face the direction of movement. But if I want to smoothly rotate to a direction, sometimes the player will take the "long way around" (i.e., player is at -90 degrees, facing right; I press S and it will rotate 270 degrees to be at 180 degrees, facing down). How can I fix this? I tried adding 360 to the desired angle until it was within 90 degrees, but that didn't work (probably just because I'm too tired, though). Any help is appreciated!
Asked
Active
Viewed 46 times
0
-
? Not the same question – Jimmt Dec 17 '14 at 07:54
-
1You need a proper getAngleDifference function. http://stackoverflow.com/questions/1878907/the-smallest-difference-between-2-angles – user55564 Dec 18 '14 at 00:17
-
@user55564 that link was actually really helpful, thanks! – Jimmt Dec 18 '14 at 02:33