How can I save info about destroyed actor?

I need help with figuring out of how to keep AI enemy actor being destroyed after loading level through saved slot?. If is there already answer exists, please, be kind and write a link.

You could add a bDead flag to the enemy class and set it to true instead of destroying the actor. Then if the flag is set, skip ai processing, set visibility to false and disable collision.

give each persistent enemy a unique name, and give the GameInstance an array of names of killed enemies. when you spawn an enemy, check if you can find the name in the GameInstance array, and if so, don’t spawn the enemy.

if you want these enemies to stay persistently dead between game sessions, you can save that array to your save game. you can also use this same list for other persistent objects, like treasure chests or pickups that shouldn’t respawn.

Thx for the answer! Unfortunately I haven’t solved problem. Sorry for being so noob, but can you show me an pictures of example?

it should look something like this:

1 Like

Thank you so much! It’s working!

Hi! Sorry for bothering you. Can you give me a tip on how to save persistent state of destroyed object? Can’t handle these arrays.

give your save game an array of names, then when you want to save, set that array with a copy of the GameInstance’s PersistentItems array.

kinda like this, but instead of a struct called inventory, use the array of names. (or put the array of persistent item names inside a struct called inventory, so you don’t have to rewrite your save/load code every time you want to add new variables to save. )

Thanks for answer. Can’t say it works or not. I’ve created another project and met another problem - as event begin play fires, all of pickups seems to be destroyed :confused:

make sure you are checking that find name returns greater than -1, and not EqualOrGreater to -1. and make sure each pickup has a unique itemID name.

I’ve checked that find name is greater than -1 and that names of items in instance are same as names of pickups.



well, if your begin play isn’t working, post an image of your begin play function

empty out the default array of names. any items that match names in that list will destroy themselves, because they were already collected.

Cleared names from instance array, and they aren’t destroying now on begin play. Sorry for takin your time. Still, state of object can’t be saved.

your Save variable should be a SaveTest type.

that way it will contain all the variables from your specific custom SaveGame, rather than the generic default SaveGame.

you might be having a problem with object slicing, which is when a base class is casted to a more specific class, and you lose any data that the base class was missing:

make Save a type of SaveTest variable, and try setting up the save/load functions a bit more like the picture i posted a few comments above.

Would you please give screenshots of the whole concept ? its not working, what i want is that the destroyed actors should remain destroyed even after closing the game , and where do you put the Die ( custom event ) event shown in your screenshot ? i have only one level now and ive drag dropped the AI’s in the level ( on the nav mesh bounds volume )