How to assign properties to all group members in python?

I would like to assign properties to all of the group members of a Group instance.
I have this script:

added_object = own.scene.addObject('GROUP-BOX', own, 0)
added_object.groupMembers.color = (r,g,b,1)

How can I write it to assign this color change to all of the group members?
And is there a way how to delete the empty for the group instance?

owner = bge.logic.getCurrentController().owner

added_obj = owner.scene.addObject("group_obj", owner, 0)

for obj in added_obj.groupMembers:
    obj.color  = (1,1,1,1)
   obj["prop"] = "whatevs"

# i think this works, i havent used groups years

obj = added_obj.groupMembers["name_of_specific_obj"]

simply put an end object brick on the group empty

1 Like

Thank you, I’ll try that when I’ll get home.
Concerning the empty of a group instance, I’ve put the end brick on the empty group instance but it deleted the whole group of objects and not just the empty. Do I have to ungroup the objects?


If you add the group instance and delete it, you delete the entire group, so you can’t delete the empty only, because it is the “root”. Anyway, the empty not calculated like an object with a shape, so it is very light (in data consumption).

Writing for item in owner.recursiveobject work too, but it depend where the script is started.