Functions not reading object transforms from editor as expected

I am seeing some discrepancies in transform values in scripts vs. what is displayed by the Unity Editor.

For example, if I look at an object transform.rotation in my editor it will have a x angle of 30 degrees. I hit play. The angle in the editor still says 30 degrees. Reading the SAME value x during Awake(), Start() or Update() is 0.25858 (varies slightly from run to run). Why is x not getting updated to 30 degrees from the editor during any function?

I’ve looked around and am not seeing other answers yet (I did see a similar question with no answer).

I’m using Unity 5.0.1.f1. Thanks in advance.

Transform.rotation.x isn’t what you think it is, those are separate values used by the Quaternion to represent the rotation. You probably want to use transform.rotation.eulerAngles.x.

2 Likes

@GroZZleR : Yes, you are right! I was thinking in Euler when I was looking at the angle values, not the Quaternion. I was just figuring that out when I saw your reply. Thanks!!