Search Unity

  1. Click here to receive a gift with your purchase of Unity Pro or Unity Enterprise.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

rotation from editor different from script ?

Discussion in 'Scripting' started by patricia, Sep 30, 2007.

  1. patricia

    patricia

    Joined:
    Aug 10, 2007
    Posts:
    73
    I'm having a problem,

    basically i notice that the values i see in the editor are not the same as the one in the script.

    myobject.transform.rotation.x is different from what i see in the editor.

    Why is that ? and how to get the correct values ? ( even if i force the rotation of my object by script i don't get the same position for my object ! )

    pin.transform.rotation.x = 0 lays it flat on the ground by script. but rotation.x = 0 stands up in the editor.
    I'm so confused :s

    the bottom text in the screenshot is Debug.log ( quille.transform.rotation.x + " - " pin.transform.rotation.y )

    as you can see, the editor rotations are different.

    helppppp ! :)
    Patricia.[/img]
     

    Attached Files:

  2. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,973
    It doesn't say the rotation of the object in the editor, but it says it's euler angles, I think. It would be something like:

    Code (csharp):
    1. myobject.transform.localEulerAngles.x
     
  3. aaronsullivan

    aaronsullivan

    Joined:
    Nov 10, 2005
    Posts:
    983
    Right. The euler angles are in the editor.
    rotation is a Quaternion. If you aren't familiar, you can look them up in the script docs. Basically, the x,y,z component of the Quaternion are totally different than the euler angles most people are used to in 3D editors. There is never a simple direct correlation between the two either. :D
     
  4. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,356
    If you change the inspector to debug mode it will show the quaternion components of the rotation.
     
unityunity