Reset level but not reset variables

I’m having the same issue as this thread https://answers.unrealengine.com/questions/214804/restart-level-but-not-reset-a-variable.html but I’ve been unable to solve it. After reading the comments I moved the variable into a custom Game State. Essentially, to test this, what I’m doing is a quick sequence.

  1. On begin Play, casting to the game state, then running through a Branch comparing an INT that’s defaulted to zero, and then printing a string if it’s zero.
  2. I’m adding 1 to the INT.

On Exec Command: RestartLevel - the printed string will trigger every time. It won’t go up to 2, 3, or 4 - it’ll just print the string and add 1 to the Int, then default back to 0 to do it all again.

Essentially, I want to be able to dive back into the gameplay without playing my starting UMG sequence again, but… i’m probably going to want to keep track of variables for the long haul - like total times played, etc. Am I going about this the wrong way?

Some threads said there was a bug that was addressed in 4.8, but this seems more like a logic mistake than some sort of bug. I’ve also tried moving the variable into the Game Mode and still not luck.

Game Instance - persists through level reloads etc. survives until game close, at which point you’d save the data using the standard savegame method in the wiki.

If you are saving games for reload (save file) then you could also save at death and reload upon death. It may consume a little time, but on the plus side, if the game crashes at respawn all the player data is already saved.

yeah, that was it. I found some awesome game instance stuff here UE4 - Using Game Instances & Persistent Variables - YouTube

and then, once i realized i had to go into project settings to turn it on, that was pretty good. Still haven’t messed w/ save files, but I guess that’s next. It’s well documented so… yeah, time to dig in! :slight_smile:

Thanks again! :slight_smile: