Download

Saving variables when changing map?

Hi there.
I’m making an RPG game and I need my character to travel through some maps, but when you use the “Open” command, all your variables are reset in the new map you load.
Is there no way to keep your variables intact? I saw that it could be done by saving my variables in a savegame and then loading the save in the next map, but I’m not if that would work properly.

Hello,
Have a look at this tutorial made by The Britain about game instance : https://forums.unrealengine.com/showthread.php?54335-Gorilla-Gong-Tutorials&highlight=game+instance to see how do it.

I see how that works. However, isn’t that kind of a pain in the ***? I mean, what if you have a gazillion variables on your character you want to save? Do you have to have all those variables in the game instance and access the game instance all the time to get the values? Isn’t there a way to get all the variables to the game instance and then reload them on the next level?

Game instance is to used only when you change level or quit game. Set all in character or best usefull blueprint, use when needed and do game instance save load only when needed.

Edit : Maybe a struct can be usefull in that situation but i haven’t used them enough.

I’m not sure what you mean. So, should I have all my variables calculated in my character, then before changing map save them in the game instance and then on begin load re-set the data to my character?

If i don’t mistake this is what i’ve seen done. Use what you need when and where you need and when you have to save, transfer to game instance and save there.

I see. It’s kind of a hassle, but it seems to be working.