http://zippy.gfycat.com/MilkyKnobbyBorer.gif
So I have a spaceship that is rotating towards the mouse, but whenever the cursor crosses the positive x-axis (0-360) the spaceship takes the long route all the way around (see gif). How can I fix this?
LookAt code:
public float lookAt(Vector2 target) {
return (target.sub(new Vector2(position.x, position.y)).angle());
}
Other:
rot = 270 + lookAt(new Vector2(tarX, tarY));//get rotation towards mouse position (tarX,tarY)
angle += (rot - angle) * 0.1f;//smooth out rotation; this is what is applied
Thanks