How to delete an object which has been added by an ADDOBJECT actuator ?

Hi every one !

For a simulation of fire spread i add with a EDIT_OBJECT actuator a “particle object” "that’s representing the fire to a building.

My building has a GameProperty health. When this property come to 0 I would like to make disappear the fire.

I was thinking by adding my fire by script. In this script i will create my “particle object” and add to it a MESSAGE Sensor, ADD Controller and EDIT_OBJECT to END_OBJECT.

But I’m not sur that’s possible during the game…

Can any one help me ?

Thanks a lot.

You cannot add logic bricks to an object during a game. You cannot “create” new objects during a game. Every object that you want to use must exist before you start the game.

Set up your particle generator with its logic bricks ahead of time, and put it in a layer that is not visible in the game. Then make your building add the particle generator object with Edit Object >> Add Object when the building health is 0. It will do what you want it to do.

triguN - please have a look at blendenzo’s post and note this: he actually sugestive an “alternative “algorithm””. That’s what’s keeping the Logic brick editor fun and challenging - you always have the Freedom to use your Creativity in order to implement your ideas.

Therefore, as blendenzo said, there is no need to actually achieve similar to real-life effects: simply using visibility instead of object creation/deletion is one of the alternatives to your issue.

Just try to figure out some things for yourself, put them together (design your algorithms), and you’ll notice there is no need to get complicated :slight_smile: - simple sketches will do (but you must know what are the TOOLS you have at your disposal - C, Python, and the Logic Brick editor are some extremely good examples, otherwise you will not be able to program if you don’t know the “sintax” :wink: )

Thank you both for your answers !

@blendenzo’s : I’ve already make what you said. My “Particle Emitter” is on an other layer and I add it with Edit Object >> Add Object.
But my problem it’s to delete it. To be more clear, I generate a city of 500 buildings. Each building has 2 game properties :

  • health - int
  • isBunring - bool

The health of a building is initialized by its height. isBurning is initialized to flase. When I turn it to true, then a script start each 2 seconds, and launch somes rayCast to detect buildings around. At the end of the script I decrease the health by one and that for each building burning.

Well, that’s how it’s working. I succeed to put fire on those buildings burning, but how to get the “fire” on each building ??
With the Edit Object >> Add Object I cannot know the name of the object added.

Like chrisiani_if says, it would be easy to set the visibilty of the fire off, but I cannot get this object !

I don’t think you have to - try an alternative method:

Make each building of yours to have an empty (at the same time/after the building is created), and make the empties remove all fire objects(which should have a specific property) in a certain range (you could have multiple versions for e.g. “large/small” buildings) when triggered (not greater than the area occupied by the building) - when a building reaches 0 health, it should trigger its empty to do the removing.

You could also have the empties create the fire or “activate” the closest fire object in range when you desire it to happen…

No no no, wait - here’s the thing, but simpler:

First, position the buildings’ center somewhere around their base, where the fire should be generated.

Next, have each(all) building to remove all objects with a “fire” property in a certain range when health reaches 0.

(you could also use the buildings’ centers to add the fire objects)

There is no need to refer to each fire object - just a simple “near” (or radar?) actuator should be enough to have the fires removed As you Want them to…

Thanks chritiani_if for your idea(s) !!

I’ll work on it and give you a feedback of this !