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

Laser groups of 1/2/3/4, how does ECS/DOTS handle children?

Discussion in 'Entity Component System' started by goodnewsjimdotcom, Jun 4, 2021.

  1. goodnewsjimdotcom

    goodnewsjimdotcom

    Joined:
    May 24, 2017
    Posts:
    342
    So in my normal mode of gameobjects, I have 4 different prefabs of lasers. Each prefab holds a group of lasers 1/2/3/4. Each laser has a rigid body to collision detect itself while the other up to 3 lasers have their own individual colliders.

    If ECS/DOTS had children,

    After conversion to entity of a laser group, I could access children by transform.GetChild(x) to place on physics shape/body. But I am unable to get the child of an ECS entity. How do I do that?

    Is it possible I make new prefabs with laser having shape/body on them? Cuz that would solve it too.

    Thanks,
    Jim
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,627
    There's a buffer called Child with all of an entities children.
     
    MNNoxMortem likes this.
  3. goodnewsjimdotcom

    goodnewsjimdotcom

    Joined:
    May 24, 2017
    Posts:
    342
    Ty you very much Mr. Carvey.
     
  4. goodnewsjimdotcom

    goodnewsjimdotcom

    Joined:
    May 24, 2017
    Posts:
    342
    Lets say I'm in a MonoBehaviour, IConvertGameObjectToEntity

    where I have both the gameObject and entity reference at this point.

    How do I access said buffer with entity?

    Ty, the documentation online is poor. I'm thankful for the community
     
    Last edited: Jun 4, 2021
  5. goodnewsjimdotcom

    goodnewsjimdotcom

    Joined:
    May 24, 2017
    Posts:
    342
  6. BrendonSmuts

    BrendonSmuts

    Joined:
    Jun 12, 2017
    Posts:
    86
    It’s probably easiest to add a new ComponentData or add to an existing ComponentData a field that holds a reference to the entities you are interested. During conversion you can get a reference to the entity linked to a child GameObject and store that. When the entity Prefab is instantiated ECS will remap the prefab entity reference to an instance reference.
     
  7. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,580
    I suggest you look into DynamicBuffer keywords. Plenty discussions and examples on the forum.
    Also, please check dots samples on the git. It is rich source of knowledge.
     
    Last edited: Jun 9, 2021
    hippocoder likes this.