- Home /
Changing Y rotation in Editor also changes X and Z?
I notice that if I'm not running / playing the game, if I change the Y rotation of an object in my scene, it only changes the Y rotation (es expected).
But if I play the game by clicking the play button in the unity editor, and I start to mess around with the XYZ values in the editor window for the object's rotation, rotating the object on the Y axis also changes the X and Z rotation values by a large amount.
The object rotations correctly though, I'm just confused why the editor has to change all 3 values just to make it turn on the Y axis?
I want to use a script to turn my object on the Y axis to make it look at something, but from the looks of it, I'll also need to change the X and Z values to accomplish this. Unfortunately, I have no idea how to properly calculate this.
Why do all 3 values have to change just to make the object turn on the Y axis?
Without seeing your code and game it is impossible for us to know for sure., but my wild quess is that you are seeing the effects of gravity on your object.
Answer by robertbu · Nov 11, 2014 at 08:43 PM
There are multiple euler angle representations for any given physical rotation, and Unity will change the representation. Read the euler angles section of the following answer:
http://answers.unity3d.com/questions/799824/oafatwhy-does-transformrotationx-45-not-work.html
Oh since he gave no code i didn't get that he was messing directly with rotation.y
You are of course right. He needs to use rotation = Quaternion.euler(...)
This is why posting your code is so critical if you want help.