Any way to get the list of children of a game object?


#1

There is set_parent method, but no get_parent or get_children. Since go.delete() can recursively delete all children, there must be an internal list of all the children.

Is it possible to get access to this list and request parent and children of a game object?


#2

Well, it’s been left out by design.

The rationale being that it’s all too easy to create code that traverses the scene graph, to get this or that node, in an update. This use case was very real and huge timesink at a previous games company some of us worked for.

Instead, you are encouraged to setup your structure beforehand, to know what item you want to interact with using urls.


#3

Why can’t we be encouraged to set up structures with url usage and at the same time have an ability to get children/parent if needed? Have it implemented with a side note that it’s not performant and better avoided for speed.

My use case is grouping elements (go with model) together. It’s all working with my structure (add child, remove child), but having a native way of determining children can prevent certain bugs and ease development, for instance when one element could be in two groups or if it’s in one group and actually belong to a different go.

At least for debugging it could be very useful (check how many go in a scene and find stray ones).


#4

Yes, for debugging that would be very useful at times.


#5

I think it’s possible to use profiler for debug


#6

Or DefPro: https://github.com/britzl/defpro