Game Instance - How to Reset them?

Hi everyone!

So, in a few words, I just want to reset all the variables of my Game Instance, but I don’t know how to do it.

I tried with reseting the Game with the Game Mode but it wasn’t working (I mean, I was reseting my game, but the variables of my Game Instance where still the same).

Any ideas?

Thanks!!

Game Instance is persistent so you might want to store your variables in the game mode instead. If that’s not an option for you then you have to store default values somewhere (data table or .ini) and then when you want to reset the level manually set those values to their defaults.

What are the Things you want to save and why have you Chosen the gameinstance? It’s the only class which is created on Game Launch and keeps in memory until end of game (Applikation quit). Have a Look at gamestate or If you save Server Side and it should survive only a Level choose gamemmode, If it’s Player specific use pawn or if the character can respawn use the Controller. If you need replication Look at playerstate.

I just want to reset two variables which they are related to an Actor Blueprint. (It’s an Integer Variable and a Boolean Variable)

Whenever you want to reset a variable in the Game Instance just cast to the game instance, with the input node being “Get Game Instance”, Then set the variables to what you want them to be.

If the variables are related to an actor they notmally should be - in that actor. Have a Look at the getClassDefaults Node. Im Not Sure If it works with ginstance, but you could have a good Chance. This get’s you the Default values of that class, so you can Feed Them in a SET Node and your variables Look Like in gamestart