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

Set an entity as child of another entity

Discussion in 'Entity Component System' started by Deleted User, Aug 16, 2019.

  1. Deleted User

    Deleted User

    Guest

    I'm instantiating entities in jobs. How can I set parent of the spawned entities? And also how can I modify local position, local rotation and local scale of the child object?
     
  2. elcionap

    elcionap

    Joined:
    Jan 11, 2016
    Posts:
    138
    Adding Parent and LocalToParent components. You need to set the Parent but the LocalToParent, existing, will be filled when the transform system kick in. After setting the parent, Translation and Rotation will act as the local versions.

    Obs.: If you set a parent after the transform system, it will render in the wrong position till the next frame. You will need to manually calculate the LocalToWorld matrix or invoking manually the transform system.

    []'s
     
  3. Deleted User

    Deleted User

    Guest

    Thanks!
    I have seen that parent entities have Child dynamic buffer too. What does that do? Is it required?
     
  4. elcionap

    elcionap

    Joined:
    Jan 11, 2016
    Posts:
    138
    They are created automatically by the transform system after the first pass or any change. It serves to quickly find the the children without querying and filtering chunks.

    []'s
     
    Deleted User likes this.