The object is rotated to face the direction of the red arrow. This works correctly. The rotation is smooth and no problems occur. However, I need to calculate the angle of the rotation as represented by the blue arrow.
If the object is facing the front, the angle is zero. If it turns, what is the angle of the rotation?
Now I assumed this was done using getHorizontalAngle, but I get some crazy results. When the object is stable, I get a fairly consistent direction. However, if I move the position of the object, the horizontal angle is completely wrong.
It can switch from being 315 at a stable point, to about 220 when I am moving the object. When the character is again stable, it eventually goes back to 315.
Here is the general code.
Code: Select all
vector3df rotation = node -> getRotation();
vector3df angle = rotation.getHorizontalAngle();
Any help is greatly appreciated.