Search Unity

Translations: relative vs world

Discussion in 'Scripting' started by Samantha, Sep 11, 2005.

  1. Samantha

    Samantha

    Joined:
    Aug 31, 2005
    Posts:
    609
    I've got a script that will make a plane rotate and translate when pressing left or right. The problem is that every time the plane moves, it translates relative to the angle after the rotation, instead of relative to the world.

    Is there a way I can alter the rotation without affecting the tilt of the axes, or translate the object relative to the parent's position?

    I've attached screenshots of the current behavior, along with my movement code. Any help is appreciated, thanks!
     

    Attached Files:

  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
  3. Samantha

    Samantha

    Joined:
    Aug 31, 2005
    Posts:
    609
    Thanks Joachim! I'll try it out tonight.

    Edit: it works like a charm! Now I'm curious what else you can make the transform relative to. Obviously Space.World and transform.Parent, but can you do weirder things like make a translation relative to another object's rotation? I don't know why I would want to do this, but it seems like an interesting idea.