transform.rotation not relative to world space?

Hello, I have a transform and a random ganarated map. the trasnform is above the map with 3 points in the matrix.I want to add them 2 rotation one is for always looking forward no matters wich angle the map got and one for the tilting while turning. I used transform.rotation.x … .y for that, and Mathf.SmoothDampAngle the bring the tilt back to zero. But the 2 rotation is doing something strange together, I think the axis are relative for his own transform and that’s make the problem. How can I solve this?

Transform.rotation is relative to the world, but you use it wrong :wink:

.rotation returns a Quaternion. You shouldn’t access the members of a Quaternion unless you know what you’re doing. I guess you want the rotation in Euler angles. That’s what you see in the inspector.

transform.rotation.eulerAngles.x will give you the x-rotation in world space.
transform.localRotation.eulerAngles.x will give you the x-rotation in object space.

Note that tranform has two shortcut properties to access them faster :wink:

transform.eulerAngles is the same as transform.rotation.eulerAngles

transform.localEulerAngles is the same as transform.localRotation.eulerAngles

The localEulerAngles are the ones you can see in the inspector.