Keeping global variables

Where do i store variables, that i would like to use throughout my whole game?

e.g. Standing at a faction or the gravity in a space station.

In one Level this is no problem. But how do i keep them if i load a new one.

I tried to create a SaveGame and load it in every level again. But i think this is not the right way.

Hey Phantuman,

I see you also posted this question on the forums:

Going with what Thomas Browett said in that post and what you said you’ve tried, using a custom PlayerController for your game would probably be a good starting place to look since you can access that blueprint no matter what level you have loaded as you play your game. You can also consider using a SaveGame in addition to that as you can set that up to locally save your variables from your PlayerController before unloading/streaming out a level and then restore the save when you load/stream in a new level.

We don’t have a lot of documentation available on SaveGames yet, I’ll see about getting a short write-up or tutorial put together that can explain how they work so you can get started with them and see if it suits your needs.

Thank you very much. I was able to implement the SaveGame.
I was just hoping for something like a singleton.

Can you record a demo?

UPD: use Gameinstance Where can I set a global variable that can be adjusted properly? (Loading Level reset variable issue) - Programming & Scripting - Epic Developer Community Forums