Search Unity

How to view Child of entity

Discussion in 'Entity Component System' started by Soaryn, Sep 7, 2018.

  1. Soaryn

    Soaryn

    Joined:
    Apr 17, 2015
    Posts:
    328
    So far I have found a method of viewing the parent entity, but seemingly no easy way of viewing an array of child entities. Do I need to compose that myself every frame, or is there some handler for that, that exists.


    Case scenario, I want to destroy a root entity that has 1 child node, that has multiple children nodes.

    When destroying said root, unity crashes, and if I want to further process the children I would like some way to grab an array of said children.
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    As a starting point. Unity shouldn't crash. Can you make a repro case so we can fix it?
     
  3. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    We currently don't have an API to grab children. We definately agree the there should be concepts of sets / hierarchies that automatically perform destruction similar to how it works with game objects. We currently don't have that, but it's something we are discussing on how to do exactly in an efficient way.
     
    Shinyclef, Vacummus and optimise like this.
  4. Soaryn

    Soaryn

    Joined:
    Apr 17, 2015
    Posts:
    328
    Okey dokey. I will make a repo soon. Currently streaming some silliness. For now, I'll use spare time to fiddle around with an entity child tracker... which sounds terrible if said aloud.
     
  5. Soaryn

    Soaryn

    Joined:
    Apr 17, 2015
    Posts:
    328
    @Joachim_Ante This should be enough. https://github.com/Soaryn/Demo-Unity-ECS-ParentDestroy
    The 'delete' key will attempt to destroy the "root" entity (the center cube). Once done the resulting orphaned nodes revolt.
     
  6. WAYNGames

    WAYNGames

    Joined:
    Mar 16, 2019
    Posts:
    992
    Hi @Joachim_Ante, Sorry to dig that one up but I don't think it has been solved in the DOTS stack realesed since then.
     
  7. Sarkahn

    Sarkahn

    Joined:
    Jan 9, 2013
    Posts:
    440
    Any parent/child hierarchy set up with the ConvertToEntity workflow will have a Child DynamicBuffer to access children from the parent. You can add LinkedEntityGroup (ConversionSystem.AddLinkedEntityGroup) to have expected insantiation/deletion behaviour on parent entities.
     
    Last edited: Jun 14, 2019
    WAYNGames likes this.
  8. WAYNGames

    WAYNGames

    Joined:
    Mar 16, 2019
    Posts:
    992
    Great Tahnks !
     
  9. DogF

    DogF

    Joined:
    Dec 31, 2013
    Posts:
    29
    How can we do this?
     
    BeerCanAI likes this.