Download

Question about where to store information that can persist between levels

Hey, so I have two basic questions, that are similar. Basically I’m wondering where I should be storing my variables for things like resources.

The first question is where to store them for same-level info (current metal, current wood, population max, etc) and then the second is how to store stuff that is saved between my levels (IE you have a main base where you can buy upgrades to, say, increase how much metal a quarry Actor produces per second. If you buy an upgrade in the main base, it’ll always spawn the highest level building, regardless of which level)

To start I’ve just been storing that information on the Pawn/Actor I play as as it was the simplest to do, but I’m running into problems with that as I want to be able to switch pawns, but have it remember information (specifically a RTS mode where you can select a unit and then play as it). The Level Blueprint isn’t idea as it changes per level, and I run into issues when using my main camera / builder pawn. I feel like there’s got to be an easier way, especially for saving this information, referencing it later.

And then my second question which would be saving that information between levels. I think maybe I have to make a save file for this and then reference it, but I’m not sure…

Thanks for any advice :slight_smile:

This isn’t a for sure answer, but maybe the GameMode is persistent? Try storing it inside the GameMode

You could save all that information in the player controller if you wanted easy access with different pawns.

As for persistent information between levels, you will want to use a Game Instance. Here’s a nice video outlining them.

https://www.youtube.com/watch?v=K_4CWDxwufg

Edit: ninja’d.

Yep Game Instance is the way to go, its designed specifically for this. Game mode will work for the current level but game instance will carry everything across. Or you could always throw some or all of the things you need to save into a savegame which is persistent until you overwrite it.

This is exactly what I was looking for, thanks so much