0
\$\begingroup\$

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!

\$\endgroup\$
  • \$\begingroup\$ ? Not the same question \$\endgroup\$ – Jimmt Dec 17 '14 at 7:54
  • 1
    \$\begingroup\$ You need a proper getAngleDifference function. stackoverflow.com/questions/1878907/… \$\endgroup\$ – user55564 Dec 18 '14 at 0:17
  • \$\begingroup\$ @user55564 that link was actually really helpful, thanks! \$\endgroup\$ – Jimmt Dec 18 '14 at 2:33

Browse other questions tagged or ask your own question.