I rotate my object via the usual methods:
object.transform.Rotate(attitudeVelocity * Time.deltaTime);
I am usually rotating just one axis at a time. Object point vertical gives a set of Euler angles of 0,0,0 when I use this:
attitudeEuler = object.transform.eulerAngles;
When I rotate along the Z axis, the Z Euler value goes from 0 to 359 as expected in either direction, no problem.


I also verified that rotating in just the Y axis leaves the other axes at zero.
When I rotate along the X axis, the X Euler value is fine for 90 degrees in each direction, but all hell break loose when the value is between 90 and 270:

I have comment out all code that could be manipuating the attitudeVelocity Vector3 from the first line of code above. I very rarely rotate past 90 degrees, but I am sure I have done this before on the X axis with out the others being affected.
I’m hoping this isn’t a bug and I’m just doing something wrong.
Thanks for any help!
Joe
It’s neither a bug nor something you’re doing wrong. Unity stores rotations as quaternions and only uses euler angles to display “more familiar” values in the inspector. There is more than one valid way of converting a quaternion to euler angles, e.g. (0, 0, 0) is the same as (180, 180, 180). Therefore you should not count on any one axis to have consistent euler angles, and it’s why the docs tell you not to increment euler angles and not to set only one axis.
–Eric
Thanks for the feedback, Eric. I guess I should be clear that when I say I rotate one axis at a time, it’s because I am simulating what launch vehicle would do: roll 20 degrees to the proper azimuth and then pitch down for a gravity turn. I was assuming that using transform.Rotate was using quaternions internally. It sounds like I need to keep track of the Eulers myself, is that the only way, given I need to steer to a target defined (by the user) as pitch roll and yaw.
Thanks
Joe
It is, yes. That doesn’t change anything though, since it still has to convert euler angles from the internal quaternion, and as I mentioned there’s no one right way to do that.
–Eric
Okay, that helps clear that mystery up. Thanks again, Eric!