Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Changing parent in editor changes global scale and position(unwanted)

Discussion in 'Editor & General Support' started by ClaudiaTheDev, Apr 1, 2022.

  1. ClaudiaTheDev

    ClaudiaTheDev

    Joined:
    Jan 28, 2018
    Posts:
    331
    This behaviour is new to me, so i probably just enabled by accident an option i didn't notice.
    When i reparent objects in the editor, now the global position and scale are changed (i don't want this):

    MoveStuff.gif

    What option is this, please help me♥?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    It's always been this way in the editor.

    Most likely this is just the first time you have done it beneath a scaled / rotated object.

    My general approach is to maintain unity scaling and identity rotation for ALL GameObjects except leaf objects, eg., those without children. This helps keep everything clean hierarchy-wise.

    In code when you change an object's parent there is an optional second argument you can supply to control this behavior:

    https://docs.unity3d.com/ScriptReference/Transform.SetParent.html
     
    ClaudiaTheDev likes this.
  3. ClaudiaTheDev

    ClaudiaTheDev

    Joined:
    Jan 28, 2018
    Posts:
    331
    Thank you!

    I am somehow sure i moved objects into scaled or/and rotated objects before and it worked (because i scale like every object.) But maybe i imagine things, it's so confusing haha.

    I still hope actually there is a setting, because when not it's really annoying that you can't reparent stuff without it changing global transform values.