Hi there, I am trying to rotate an object on it’s x axis and make it rotate a full 360 degrees but when i try to do that the object’s y & z axes change as well and it results in the object moving in a jittery manner. I have a simple code below:
Thanks for the reply. I have tried this out and you are right, it does work if you keep the y rotation at 0 however, the y rotation will also be changing which is why I kept transform.eulerAngles.y in the y axis. But anyways thanks and if you have any other suggestions, then please let me know
Perhaps you can show your code for the y portion rotating? Maybe someone can help you out more.
If I modify the y portion, of a rotation, the code is still working for me, I think.
I recommend reading the link I posted above. When typing numbers into the inspector, you’re not speaking Transform’s native language for rotations, and that translation is what causes most problems in this area.
If you more fully understand how and why to use Quaternion functions instead of Euler angles, you’ll have a much easier time manipulating rotations.
Agreed… the link was good. I’ve tried to get better with rotations in Unity - though far from an expert, I’ve learned a lot.
In this case, I think there might be something else going on, because when I changed the y in the inspector, the code & values continued to work properly, as far as I could tell.
First we need to establish some understanding of the concepts before getting to say it has problems and finding solutions.
The internet is full of “explanations” that are supposed to make you understand. Dozens and dozens of articles, blogs and videos about Euler angles, all saying the same thing over and over and over again but missing on important aspects.
Do you know the difference between position and distance?
If you say it’s obvious think about rotation. It’s misnamed as we’re talking about orientation in the first place. Rotation is the delta between 2 orientations.
Euler angles in the proper meaning is a system that employs a sequence of rotations using only 2 of the 3 axes to define an orientation.
Like f.i. 1) Rotate around x axis. 2) Rotate around y axis. 3) Rotate again around x axis. So 3 values but 2 axes (any 2 axes, depending on convention).
What Unity is using is Tait-Bryan angles which uses 3 values on 3 axes.
Either system has 2 ways of rotating the object: intrinsic and extrinsic. Extrinsic means the rotations occur per World axes and intrinsic means with each rotation the system of coordinates changes, i.e. axes changes and subsequent rotations are “locally” calculated.
Fortunately converting from one to the other is a matter of the order in the sequence:
In Unity you write eulerAngles(x, y, z) but the order in sequence is z, x, y and the rotations are thought to be extrinsic. This is the same as considering intrinsic with the order y, x, z.
Now I am daring to say that the problem is not the Euler angle system but in my opinion it’s the lack of the option to specify the order of rotations in the sequence. Simply specifying the sequence eliminates gimbal lock and other problems like multiple Euler representations of the same orientation, which btw I don’t see as a problem except for when comparing orientations. So IMHO when interpolating or comparing, one should convert to quaternion or better yet, something resembling the part of the quaternion that is of interest.
Oh and quaternions are easier to work with like interpolate but you work half of the time with angles and the conversion to quaternions (1) and back (2) is performed invariably always, which is very expensive.