I have a turret in my 2D game, a turret capable of firing projectiles at its target(often the main character).
The turret is rotating so it is "pointing" at the target, if it can see it.
However, the rotation speed is instant. For example, the target is at the bottom-right-edge of the map, now the target somehow teleported to the top-left-edge of the map. You wouldnt see the turret rotating towards the top-left-edge. Instead, it would just immediately change.
So I want to implement some sort of rotation speed mechanism.
Here is an idea I came up with:
The turret is associated with an object that is moving in a circular path. Lets call this circular-moving object for c.
c is following the target. Since c is restricted to move in a circular path, it cant follow the target. So by follow, I mean whether it should move clockwise or counter clockwise. How to detect this, I haven no idea.
Then, we use an algorithm explained here: http://www.gamedev.net/topic/636343-get-a-points-coordinate/ , check if the target is intersecting with this line. If it is, we set c's movespeed to 0 and the turret can fire.