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

Feedback Inconsistency In Object's Position Behaviour For SetParent() and Instantiate()

Discussion in 'Editor & General Support' started by visca_c, Jun 2, 2021.

  1. visca_c

    visca_c

    Joined:
    Apr 7, 2014
    Posts:
    30
    Transform.SetParent() by default have worldPositionStays set to true, but Instantiate() to a parent transform by default will not maintain the world position of the original object unless I explicitly set instantiateInWorldSpace to true. I find this behaviour counter-intuitive and inconsistent.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    You're not wrong... it is quite inconsistent behavior to be sure.

    But I can't imagine how they could possibly change it without breaking 99% of all projects out there.

    They would have to stand up alternate method(s) with different names and take like a half-decade to cut it over.
     
  3. visca_c

    visca_c

    Joined:
    Apr 7, 2014
    Posts:
    30
    Maybe we can mark the public static Object Instantiate(Object original, Transform parent) obsolete with a message, to encourage users to explicitely pass in the bool instantiateInWorldSpace parameter. That way, it doesn't break existing projects, but can also prevent pitfalls for future developers and projects.