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

How do you set the association between two entities in Dots?

Discussion in 'Entity Component System' started by LXF1213, Sep 28, 2020.

  1. LXF1213

    LXF1213

    Joined:
    Sep 8, 2020
    Posts:
    1
    How do you set the association between two entities in Dots, such as a parent-child relationship?
     
  2. JakHussain

    JakHussain

    Joined:
    Oct 20, 2016
    Posts:
    318
    If you want a literal parent child relationship then under Unity.Transforms there's a parent component you can add to an entity which has a field for setting what the parent is. The gameobject conversion workflow uses this.

    For relationships like this, entities referencing each other like this with your own components works well enough though don't expect to be able to follow a complex chain of entities where each of the entities can have different archetypes with very good performance.

    The collections package also gives you a few options as well.

    Does this answer your question?
     
  3. exiguous

    exiguous

    Joined:
    Nov 21, 2010
    Posts:
    1,749
  4. Shiv2k3

    Shiv2k3

    Joined:
    Jun 30, 2019
    Posts:
    118
    how do i do this through code?