# how affect all children or parent of object?

i making plataform game and want to make a basic script that will be used to every enemy ,that look like this

if conlisionSensor.positive:   #detect player atack
timer['time'] = 0
own.color = [10,m,m,1]     #make the enemy red
own['hp'] += -1            #receive damage

elif time%0.15==0:
own.color = [1,1,1,1]      #return color to normal
if hp < 1 :
cont.activate(destroy)


I want to make all children to change colors when the owner receive damage without call each one of then because i want the script to run for each of enemys without modification.

• You enemies are all children of something? Shouldn't they be independent from each other? – Monster Feb 22 '17 at 7:23

## 1 Answer

I'm not sure if I understand you correctly, but you do not need separate code for each object that has the same behavior. You can use the same sensor/controller configuration at each of the objects.

When the enemies are all copies of the same object(s) you can assign them a group and add group instances to the scene.

This way you just configure the original in Blender and all instances receive the changes. This even works with add object when running the game.