Hi everybody, is there any option of apply a property to a serie of objects and then make an actuator to affect them automaticly without doing a process for each object? for example… I create a property call: ENEMY in different object, and in my spaceship I have a powerup so when the powerup is ON it kills all the objects with the property ENEMY, do you get my point? this is just an example, I’m thinking in using this method to a checkpoint system that I will show you later the problem I have with this one, cause the logic bricks are getting mad.
in python you could make a for loop, which goes through all the objects in the scene and checks if they have a property. I don’t know if you can destroy another object with just python. But change their property or send a message that make them die or something. Something like:
obList =GameLogic.getCurrentScene().getObjectList()
for ob in obList:
if hasattr(ob,"ENEMY"):
ob.ENEMY = 1
obList will be a list of all objects,
ob is the object the for loop is currently looking at.
hassattr means HAS ATTRibute, if it has the property. Here it assumed it is an integer or float.
If if does, change it to 1
Then on your object you add a logic brick that makes it die if ENEMY is one.
Haven’t actually tested it.
Hey Men, you are AWESOME :rolleyes:
object.endObject() removes the object.
Sweet, I thought it would be one but forgot to check the API docs.
Change
ob.ENEMY = 1
to
ob.endObject()