Permanently delete a sprite from the game even when i change scenes

im trying to make it so i can collect fire extinguishers then use it to kill fire subtracting one fire extinguisher from my inventory but
how can i make sprites disappear forever? like this fire when i extinguish it, go to a different scene and come back itll be there again

You need to use global variables to keep track of which fires you have extinguished.
For example Progress.Level1 = 1, then add a condition to check for this variable; if true, delete Fire

Note: Progress.Level1 is a Structure type variable, also known as Array.
It will appear in Global Variables if you press the + sign next to it

1 Like

Structures are not aka arrays, but they can be referred to as a Dictionary. Arrays and structures are different in that arrays are index based while structures are key-value pairings. The only similarity is that they hold multiple bits of data.

I’d add an id as an object variable to the fire object. Then in the scene editor give each fire a unique value.

Before you delete the fire, store it in a global structure (say called “ExtinguishedFires”) as @reina suggested. Do this by adding a variable to the structure, with key being CurrentSceneName() + Fire.VariableString(Id) and set the value to 1.

Then, at the start of the scene, iterate over all the fire objects in the scene (use Repeat for each instance of Fire) and check if the child CurrentSceneName() + Fire.VariableString(Id) exists, and if it does delete the Fire object from the scene.


Thank you very much for the correction!
I’m always looking forward to improve.

1 Like

Thanks this trick worked! (i think? idk what im doing as this is my first time trying game development, but in the previews it worked) But anyways, if i may trouble you with another problem, i tried doing it on fire extinguishers as well

i set it exactly just like the fire so that the fire extinguisher spawns in when the global variable exists

and if i touched it with my cursor its supposed to get deleted and remove child variable thing so it doesnt spawn again but instead the fire extinguisher simply just doesn’t spawn in and i cant find what the problem is.

Other images:

You have

when I think you mean just forward1 without the FW_attainable preceding it - the structure isn’t a child f itself :slight_smile:.

1 Like

it worked! thanks again for all ur help @MrMen and @reina :))))