Strategy for storing variables across levels

I failed miserably with my attempt to store variables inside my custom character class. When the level changed, I did not have access to my variables anymore. As a workaround I used a savegame, which worked, but is obviously not ideal.

My objective is to have a place to store variables and have them persist throughout the entire application runtime. I login users on one level, change levels to a play map, then change back once play is complete.

Can anyone point me in the right direction to do the variable storage part? Do I need a custom gamestate? Something else?

Any links to tutorials or documentation on this topic would be welcome.

I’d like to keep this in c++ as much as possible.

Thanks!

Thank you!

Just to clarify:

A new instance of the game mode is not created when a level changes?

The new game mode instance is created each time when level changes.

In my opinion you should use GameInstance.