Itâs all very confusing. The Inspector shows rotation as x,y, and z degrees, but itâs LYING. As PraeterBlue notes, rotations are actually 4 incomprehensible numbers called a âQuaternionâ. Everyone (games, real stuff) uses them now since theyâre better at smoothy rotating between any angles. And by incomprehensible, I donât mean cosins and sins â theyâre way worse than that.
transform.rotation=Quaterion.Euler(x,y,z) works since it turns your x,y,z degrees into a proper rotation (a quaternion). If you mouse over transform.rotation, it even says âquaternionâ.
The extra weird thing is that it turns the quaternion back into x,y,z degrees for the Inspector, which may be different than you used. If you had rotation=Quaternion.Euler(270,0,190) Unity may decide that (-90,0,190) looks better in the Inspector. Even worse, they may be a 3rd set of values in your code. Your program can translate a rotation into x,y,z degrees with Vector3 xyz=transform.rotation.eulerAngles. Thatâs actually a function call. It might give you (-90,0,-170), which is the same angle, but it thought 190 looked nicer as -170 this time.
The end result is you can âinputâ x,y,z degrees into a rotation just fine, but you canât read them back (except for debugging) since they can jump around.