Need help rotating my ant on the Z axis towards his targetPosition
Hey, I am making an ant simulation and I want the ant to rotate towards his next targetPosition. (Only on the Z axis) For this I need to find out the angle between the ants currentPosition and the ants targetPosition:
float angle = Vector3.Angle(currentPosition, targetPos);
Then I rotate:
transform.localRotation = Quaternion.Euler(0, 0, angle);
But this doesn't work. This only rotates the ant to the upper right or lower right a tiny bit. I have looked through a lot of other forum posts about rotation but I couldn't get it to work. My understanding of rotation in Unity is complete dogshit so any help would be greatly appreciated :). Thanks in advance!
Your answer
Follow this Question
Related Questions
Parenting an object causes it to change rotation 1 Answer
Sprites only rotate by 90 degrees 0 Answers
Rotating multiple images continuously (2D) - Mobile performance/optimizations 2 Answers
Align an object rotation in relation to another object 0 Answers
How do I get the current active camera? 2 Answers