I am creating a simple 2D game using OpenGL. I want to create turrets that track and fire at the player. I have figured out how to determine the angle the turret needs to rotate to but I can''t seem to figur out which direction (to the turrets left or roght) that the turret shoulf roatate in to best arrive at the desired angle. If I just assume always rotate to one direction or the other then sometimes the turret takes the long way around, depending on where the player is. Can someone please help me figure out how to determine which way the turret should rotate. I know the exact position of the player,the facing direction of the turret, and the angle the turret should face to be facing the player. Any help appreciated. Thanks.
Ok I have no idea where this comes from or exactly how it needs to be implemented, but I''m pretty sure if you take the sign of the dotproduct of you turret forward and a vector from turret to player, you can use this to decided wether to rotate clockwise or counter clockwise around your axis, to get the shortest rotation. Hope this helps in some way.