Graph node(extra child)

So there is this Parent entity inside which i have 4 other entity as children, so when i am trying to access the children using for loop, i am noticing in the console that number of children are 5 and not 4.
That extra child is a graph node
i have no idea where it is coming form, and what can i do about it??

Hi @Ashish_Rana1 and welcome,

Are you by any chance using a model component in any of your entities?

In that case a graph node is automatically generated internally by the engine and added to the hierarchy, on runtime. There is nothing you can do about it, you just need to do a check and filter your children by their type.

For example this will return all entity children:

const children = this.entity.children.filter(o => o instanceof pc.Entity);

Thanx for quick reply, but i am not using a model component in any of my entity

Then try sharing some details about your entity setup, since graph nodes aree generally used in some components in the engine.

So this entity contain an element component of type image and 2 of my scripts.
and under this there are 4 buttons as children


this is the button entity

That’s normal, those element/button components create internally graph nodes. Check this 2D Screen in the Buttons tutorial project, how many graph nodes exist:

Looks like you are hitting this issue https://github.com/playcanvas/engine/issues/4333

The workaround is to check if the child that you iterating against is an entity type.

1 Like

yes this is the issue,
thanx to both of u for this quick intel.
by the way will this be fixed in the future???

Maybe, we haven’t made a decision on this yet as graph nodes can be added to the hierarchy. I’ve added it to our next bug blitz to see if we can address it