- Home /
Why Quaternion.Euler() works unpredictable for some values
In this example we can see that y and z values are added to y field
And here z value goes to y
Answer by AaronBacon · Nov 30, 2021 at 01:10 AM
The answer is pretty simple, the "change" in values are just 2 ways of representing the same rotation. Like here I've set up your second example with the 2 cubes having the different rotation values:
⠀
⠀
As you can see, the 2 objects have Identical rotations (The Arrows are showing their Local X,Y and Z Axis) despite rotating around different axes to get there. So in your examples, you're converting the 3 floats to a Quaternion then asking to convert it back when you look at Quaternion.eulerAngles, so there's no guarantee that Unity will decide to rotate round the same axis that you did.
⠀
This is actually one of the reasons why Quaternions are better than Euler Angles for representing rotation, as you can't have 2 different Quaternions evaluating to the same rotation, which is handy if you want to know if 2 rotations are the same, even if technically the axis' they're rotating on are different.
Your answer

Follow this Question
Related Questions
Good Solution for Camera Movement 4 Answers
TransformDirection and Scale 1 Answer
Gyroscope Tilting Rotation. Quaternions T_T Help. 1 Answer
Cant Rotate in Unity Survival Shooting Game tutorial 0 Answers
move based on camera position 0 Answers