get child python

Hi all :slight_smile:

Can someone tell me how a parent can acces to his children ?

i know that a chil can acces his parent with own.getParent() but what about the parent ?

I need to know it for my stupid IA :D:D:D

thx

I don’t think a getChild() method exists.

That doesn’t surprise me though, because while each object can have only one parent, it can have multiple children. So even if such a method existed, you would still need to keep track of a specific child by name.

Which is probably why something like that was never included, because we already have:


object = GameLogic.getCurrentScene().getObjectList()["OBObject"]

um…i’m not sure… never really needed it, but it woudl be kind of usefull. maybe just give all children a certain property? and kind of filter with that

ok i will find another solution.

thx anyway

Solution found !

in the Logic window, link your parent’s python script controller to a child’s actuator

then, in your python script :

import GameLogic as g

cont = g.getCurrentController()

actuChild = cont.getActuator("Name")

child = actuChild.getOwner()

KX_ObjectActuator

:smiley: