I’m making a 2D game, I’m using Vector3.RotateTowards to rotate a vector toward the wanted vector.
Vector3 aimDirection = GameShmupController.instance.GetPlayerPosition() - GunPosition;
currentShootDirection = Vector3.RotateTowards(currentShootDirection, aimDirection, rotateSpeed * Time.fixedDeltaTime, 0.1f);
this works as intended if the angle difference between aimDirection & currentShootDirection is small. However, if the player is behind the enemy, then the enemy will do a weird flip in 3D space. Instead of rotating around in the 2D space (x, y), the enemy will flip like a paper flip around to try to look at the player.
How do I rotate this vector currentShootDirection toward the vector aimDirection in 2D space only?