Ok, this might be a fundamental math problem, but I'm not getting it, maybe I need a little tip.
So, I have a unit (top-down-view), which is rotated at 0° when looking up (north), 90° when looking east, 180° south, 270° west and there is no 360°, it goes back to 0°.
Let's imagine the unit is looking east (90°), and I received a new rotation that the unit needs to smoothly transition to, let's say this is 340°.
Now I need to figure out if I need to rotate the unit clockwise or counter-clockwise. In this case I need to rotate counter-clockwise since it's the shortest distance to the new angle (I only need to rotate 110° instead of 250° if I would rotate clockwise!).
How would you do this?