Component Entity Child/Parent Hierarchies

We’ve been building characters in our project built out of multiple component entities, and we keep running into the problem of needing some ability in the code to define a linkage between these entities so we can have one entity make requests of another one.

In the old entity system there is a concept of Entity Links, which is one way to do this, but there doesn’t seem to be anything equivalent for component entities.

Using the transform components, it’s possible to define a hierarchy and each entity can thus know its parent, but there is no way for a parent to know its children. Making the transform component store its children and allow querying of that might be one solution here.

We have gotten around this so far by writing our own Hierarchy component, which we give to all entities in a group, and it lets us track the child/parent relationship between entities. This feels a bit clunky though.

So I’m wondering if there are plans to handle this better?

Yeah, that’s kind of what we’re doing with our Hierarchy component. But we’ve found ourselves several times in the situation where we wanted to know all of the children of a particular component entity, where the children have been defined via parenting in the transform component. So the obvious improvement seems to be added child tracking to the transform component.

You could maybe write an EBUS implementation for that, so that the children can get called over the event system.

Another solution might be an component that implements a kind of observer pattern. So the children register themselve on initialisation.