Search Unity

child object ignore parent rotations?

Discussion in 'Editor & General Support' started by Gibbonuk, Feb 3, 2014.

  1. Gibbonuk

    Gibbonuk

    Joined:
    Dec 10, 2013
    Posts:
    175
    Hi, I have 2 objects and I simply want to have one object "move" with other but not rotate?

    So for now i didnt do any parenting i just added a script:
    Code (csharp):
    1.  
    2. var obj1 : GameObject;
    3. private var pos : Vector3;
    4.  
    5. function Start () {
    6.     pos = transform.position-obj1.transform.position;
    7. }
    8.  
    9. function Update () {
    10.  
    11. transform.position = pos+obj1.transform.position;
    12.  
    13. }
    Problem is I want to eventually create a multiplyer so will need these to be a single prefab, plus moving them in the editor is annoying as I have to move both.

    So my question is, how do i stop the child rotating with its parent?

    Thanks
    Andy