Saving data between levels. How to go about it?

Hi there.

So I’m currently looking into saving when going between levels, but I can’t get my head around how to do it in a good way.

What I have is the following scenario:

An overworld map with X amount of Armies.
Each army consists of 12 squads.
Each squad is between 1-9 soldiers.
And each of these soldiers have stats like Name, experience, skill etc that is saved between battles

What I would like to do is save the armies in an array in a Game Instance asset. And each of those Army actors contain an array for each squad in that army, that should contain the variables for the stats of each soldier in that squad.

But here is where I’m at. I am not sure what kind of asset to use to store those variables. A Data asset? A Blackboard? Just plain actor blueprint? Or something else entirely?
All I need to store are a few strings, bools and floats that I can then load when a battle is started.

1 Like

You say this, but how is that happening at the moment?

Hey @Emil_J!

Yeah I’d go with a Data_Asset class for each soldier type that can be called up when needed, or even a Data Table.

If the soldiers are highly specific (IE Steven, Amanda, Jacob vs Bomber, Striker, Sniper etc) you won’t want to do that, you would want to create an instance of a “Soldier” struct blueprint that stores data like HP, Speed, Range, whatever. Then add that to the array on the game instance. :slight_smile:

1 Like

It is not at the moment… that is what I’m trying to figure out.

At the moment it’s just pawns with a blackboard that would get wiped as soon as the level transistions.

1 Like

Ok.

The main way to do this, is with the save game.

Rather than trying to organize this for all these people all at once ( which will not go well ), I’d recommend teaching ( coding ) the soldier so they know how to save and load their own data.

That way, you just have to get them to save before you go to the next level, and load when you have entered the new level

You make make a struct, that suits all of them, which holds these basic variables. Then all the save game needs is an array of these structs. Each soldier gets an ID, which is their offset into the array.

1 Like

Of course there is a “HTF do I?” :smiley: Been trying to find on for weeks now.

Yes this sounds exactly like what I’d need. I’ll give it a swing and see if I can manage to hook it up correctly.

1 Like

This does indeed work perfectly. Thank you very much!

1 Like