is this upbge?
in any version (bge or upbge), what i do is put an int property in the object that you will spawn, called something like “ID” or “NPC”. then i create all objects in python:
obj = cont.owner
scene = bge.logic.getCurrentScene()
#find all objects with the property and count them
aec = [abc for abc in scene.objects if "NPC" in abc]
#spawning an object will spawn all it's children
ob1 = scene.addObject("enemy", obj, 0)
ob1.worldPosition = obj.worldPosition
ob1.worldOrientation = obj.worldOrientation
ob1["NPC"] = findObjects()
all objects will have a different number in their property, you can find the correct object by looking at the one with the property with the matching number:
objList = bge.logic.getCurrentScene().objects
sel = 2
targets = [abc for abc in objList if "NPC" in abc]
#find the object 2
selected = [aec for aec in objList if aec["NPC"] == sel]
#you can change the object here
i think what you wanted to do was access the children of a parent object, you can just do
object.childrenRecursive, but only in bge. in upbge it’s read only.
in upbge what i did was put a script in the lifebar and do:
par = obj.parent
obj.color = [par["unitlife"]/100*par["tlife"], 0.0, 1.0, 1.0]
it is much better for lifebar and also works in bge.
in upbge you can also rename objects by:
ob1.name = "name"
i hope what i wrote is of use.