- Home /
Inaccurate rotation if object is rotated on two axis at once
I have an object which i want to rotate relative to world space. I have three variables (one for every axis) which store the rotation. By pressing buttons on my controller I add or subtract 90 to these variables (rotX, rotY, rotZ). Then I rotate my Object like this:
transform.Rotate (rotX * delta, rotY * delta, rotZ * delta, Space.World);
As this is called every frame the object would spin forever so i subtract the ammount I've allready rotated afterwards:
rotX -= rotX * delta;
rotY -= rotY * delta;
rotZ -= rotZ * delta;
This works fine as long as I don't rotate two axis at once. Then the object rotates rotates only partially to the desired position (e.g. 83 if I want to rotate to 90).
I can't see what i've done wrong.
Thank you in advance and have a amazing day!
Comment