Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

how to change the relative position in mixed transform

Discussion in 'Editor & General Support' started by coldpl_ay, Apr 23, 2014.

  1. coldpl_ay

    coldpl_ay

    Joined:
    Jan 20, 2014
    Posts:
    36
    Hi,everybody!
    GameObject A has child B(0,0,0) ,C(1,0,0) and D(2,0,0), A's position meant to be around C's position. But I want A to be at (0,0,0), when I changed the child gameobject, A is changed automotically, it does not follow my wish.
    How can I change A's relative position as my wish, mainly to child's relative position?:)
     
    Last edited: Apr 23, 2014
  2. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,952
    So you want to move C, and have A move with it?

    It won't happen automatically, as children inherit and parent's don't. You can do it through code, ensuring that whenever C moves the parent moves, but be careful as when you move A, C will move too. You will get a ongoing loop. It might be easier if you want move C, just move a instead. Or just restructure your hierarchy to better reflect the use case.
     
  3. coldpl_ay

    coldpl_ay

    Joined:
    Jan 20, 2014
    Posts:
    36


    thank you for your answering, maybe I didn't make my meaning clear.
    see the following pic:
    $copy.png

    GameObject A has 3 children objects(B, C, D). A's position is now near C's position. I want A's position near B's position, as my wish. how can I do that?
    the result I want is like this:
    $2.png
     
  4. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,952
    Do you mean during runtime or just in the editor? If in the editor, just grab all 3 children and move them till the are correct.
     
  5. coldpl_ay

    coldpl_ay

    Joined:
    Jan 20, 2014
    Posts:
    36
    It's in the editor, I tried as grabbing all 3 children, but A's position is also changed.
     
    Last edited: Apr 23, 2014
  6. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,952
    It shouldn't. Do you have Pivot or Center selected in scene tools?
     
  7. coldpl_ay

    coldpl_ay

    Joined:
    Jan 20, 2014
    Posts:
    36
    I don't understand your meaning, can you have a screenshot to help me? ( "Pivot or Center selected in scene tools" ):D
     
  8. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,952
    At the top of the scene window there are some control buttons. The one marked "Pivot" or "Center" controls where the control axis is. Pivot means the actual center of the transform. Center means the center based on the size of the object (including children).

    $pivot.jpg
     
  9. coldpl_ay

    coldpl_ay

    Joined:
    Jan 20, 2014
    Posts:
    36


    thank you, You resolved my problem ! :D