Hello, When I have an Enemy die I want them to be added to an array when you save the game the array saves also when loaded, all enemies in the array are instantly destroyed. How do I do that?
How are you loading the game? It sounds like you have not implemented a SaveGame object yet (see: https://docs.unrealengine.com/en-us/Gameplay/SaveGame). Once this is done, you can specify what actors you want to be saved/loaded.
I used the Save/Load Tutorial from UnrealGaimeDev a while back https://www.youtube.com/watch?v=xe1AEg7XyJw. I decided to expand a project I made and I’m having trouble with this.
My take on it, many ways to do it, and really depends on your requirements, but here goes:
One blueprint controlling spawning of enemy actors, from an array of either structs or actors(I will use structs as example, something about traffic and time transferring 1 struct vs transferring multiply variables, really depends on how complex your enemy becomes)
So 1 master blueprint, holding an array of structs- each struct contains actor class, dead or alive bool, health, location, size, etc etc.
Flow: master checks if new game or continue from saved game then spawns enemy actors via for each loop,
> with a simple branch using alive/dead,
> if dead, no wasted resources spawning then -destroying actors.
When Enemy is damaged his variables are feed back to the masterBP.
On save game, or on significant events the master saves the array.
From respawn or continue from last save load save game data is feed into the master before spawning enemy.
This allows enemy to only spawn when alive, health stats feed into surviving enemy etc.
This will allow the masterBP to alter spawning and enemy variables based on damage and kills inflicted on enemy by player, triggering group behavior, could work time to kill into it, if player is destroying enemy to fast, alter spawn rate and patterns, all sorts of possibility.