Save and Load Dead Enemies

Hello, I am trying to save enemies the player has killed in my save game object and when they are loaded they get destroyed immediately. I have tried several ways such as storing an IsDead? boolean in the enemy and then saving it to an IsEnemyDead? in the game save then when loaded if it is true it destroys the enemy but the casting to Enemy failed, I tried using an array but that didn’t work either. Any Ideas?

How do you spawn these enemies into the level? You must have some method that says Enemy “X” goes here, Enemy “Y” goes there. So whatever that method is, you should have an array of bools and when Enemy “X” is killed set the bool to true. Save this array out to your save game object. Then when you load the game back up have the spawner check the bool array and see if the enemy was killed, if yes, “spawn and destroy” or “skip” the index and move to the next. If they are statically placed, have a function in the level BP that checks this bool array against the enemies and if they are killed destroy the enemy instance.

The Enemies are in the level already, I dragged and dropped them into the level (multiple of the same enemy as well).
I’m not really sure I understand what you are talking about, I am new to arrays and saving and loading as is. Could you provide some screenshots if possible? Thanks for helping.

Here, I made you a tutorial explaining how to do this. Hope it helps

The Link says the video is unavailable.

Edit: Link started to work

Sorry, def had the wrong release date on YouTube, try it now haha

I am having a bit of trouble implementing this into my project, I did follow the save and load tutorial by UnrealGaimeDev’s RPG Tutorial Series ([Eng] Complex Quest System: Adding a Slot-based Saving System 1/3 #26 - YouTube) How would I use the code in your tutorial in that project?

What exactly are you having trouble with? I skimmed the link, it would seem you would just need to add everything I did into your character BP instead of how I did it with save/load separated from the player into the game instance and the level BP handling which actors were present at the time of saving. Because this “save/load” system is entirely contained within the player character I don’t find it scalable. Placing it into the game instance would make it easier to keep track of things and not have everything that needs to be saved run through the player character. Imagine for every level if you want to save something the player character will have to have references to every single possible thing you want to save or create them at runtime. This is not a great way to handle saving “game state” for something like killed enemies which my tutorial is handling. For something like an inventory system that may not be an issue but for what you want to do I think this will be a headache later on. My advice is to create your “save/load” functionality within the game instance like I did and simply add UnrealGaime’s inventory save functionality into the main save/load you create in a game instance. This way you can pass data from the player about the objects he holds/stats to the game instance and save them without having the player need to know how many enemies were killed in the level. The level BP can handle that and pass that info along to the game instance during a save.