how do you get the rotation of an object?

may be a dumb question but (knowing rotation is set differently than position) i would like to get the rotation of an object and store it to a varable. i tried to display transform.rotation.x but it didnt display the right number. how do i get the rotation?

transform.rotation is saved as a quaternion. Are you looking for transform.eulerAngles?

im looking for the 360 degrees type answer

yeah. Euler Angles. Didn’t you look in the scripting reference?

yup and it works

What I do to read it is:

var objectRotation : Vector3;

function SomeFunction()
{
  objectRotation = transform.rotation;
}

It saves it! Of course, to apply it, I have to use the Quaternion stuff, as below:

transform.rotation = Quaternion.Euler( objectRotation );

:slight_smile: