inverse expanting KX_GameObject

Is it possible to “improve” a KX_GameObject to only allow it to have 1 child maximum at any time?

If so, how would i go about it?

Why would you want it to only have one child at a time? There’s no built in way to change the maximum number of children a game object can have. The best you could do is write a Python script to monitor the children list of the parent to see when it changes, and deparent the oldest entries until only one child is left. Or, on parenting a child, loop through the parent object’s children list and unparent all but the current child from the list.

Ye, just as i thought. Well i basicly hoped to limit it to 1 so that i could save some work, so the bge would handle it without
me running additional code.

I have an Inventory, that has cells(empties) and i child items to it, so they move with the inventory.
As there will be by design no stacking items, i hoped to limit it with this.
Now i use a extra variable that is contaning the item.

Thanks nontheless.

You can simply check if the potential parent already has a child.

If you wanted to perhaps change this variable later on, you could write a subclass that overrides the setParent method by monitoring the number of children, modifying the existing children if needed.