Save - Load - Enemies


I am using save/load functionality, however I have one problem.

when I load the saved game, then the enemies which I destroyed earlier appear again

is there a possibility that destroyed enemies not to appear?

How ? What i need to do ?

Thank you

Take note of which enemies were destroyed, save this data, and after loading, delete these enemies.

1 Like


How to take a note of destroyed enemies?


You have to do it the same way as score and player position.
We don’t know your enemies, but they must be own objects or instances with id variable.

1 Like

Ok. do you have any idea how to put them as objects or instances with id variable ?

how to count destroyed enemies ?

Thank you

Can be improved with structure-variables and while-event if you have a lot of enemies, but that’s how it works.

1 Like


thank you. I will try to do that now.

hmmmm. this solution is hard, because if i will have more than one enemy.
please can you show me how could i do it with structure-variables ?

I have tried this, but it is not working :frowning:

I’ve never done it, but like this.

1 Like

Hi Jack,

I will try that.

can you please explain how this technique works ?

So that I can try to understand that.

why is counter less 20 ?

Thank you

20 is the number of your enemies.
Checking for an enemy id is repeated 20 times instead of writing 20 lines of code.

1 Like

so basicly if I have for example 53 enemies. Than i need to write 53…


thank you

I tried now, but now my load button is not working. :frowning:

when i remove this few lines of code, then again it works.

can you maybe send me this as file, so that i can try it on my computer.

thank you

did you set the ids for all enemies?

1 Like

I have done this:

but now load button is not working… :frowning:

I think that is now working without lines: While these conditions are true:

and Repeat there:

all other lines are still here.

but i need to test more.

just one thing, can i put diferent ID for the same enemy ?

like this:


for example i have two objects: SlimeWalk

the first one has ID 1, and for the second one i want to have ID 2

but for some reason if I change the second one to ID 2

then the first become ID 2…

why ?

You have to, that’s the sense of IDs. For other enemy types, than you can copy the whole thing, with different object names.
I know it’s not that easy to understand how to select and address different instances in GD. It is best to try the simplest possible structure, outside of your project. so not get confused by all the other conditions and actions.

1 Like

Great. I will check your project.

Thanks for your help :slight_smile:

Hi Jack,

after I looked at the file, now everything is working properly


I used the same technique for coins also.

please see image:

I have set the same parameter for coins, normally different names.

coin counter was also less than 20

and for testing i have put id 1, id 2, and id 3 for three coins.

and when i collected first coin, after load

the coin was no longer there, however also the first enemy was not there

I guess because the first enemy also has id 1

and now i have changed coin counter to less than 200

and for coins i have puted id 100, id 101, id 102

is this ok ?

can IDs be high numbers ?

because now everything works including coins.

Thank you again

This shouldn’t happen if you have another group name(toDestroy/coinDestroy).

High IDs should be okay.

1 Like