Restart level but not reset a variable?

Hello,

So I have a little script that when the player dies the world resets, and spawns the player at a certain location.

I have a checkpoint system which sets this certain location, but when the level restarts it set back to zero.

How do I reset a level but without setting the variable?

You have to store it somewhere else. Game state object? Game mode object? Savegame file? Depends on your specific needs.

Alright, can you elaborate on the advantages and disadvantages of each or link me to somewhere that does?

The documentation lays out what the different classes do: https://docs.unrealengine.com/latest/INT/Gameplay/Framework/QuickReference/index.html
Specifically, look at: https://docs.unrealengine.com/latest/INT/Gameplay/Framework/GameState/index.html
And: Game Mode and Game State | Unreal Engine Documentation

I think what you want for this case is a GameState, although it could be a PlayerState perhaps.

Using LoadMap() to re-load a map after death sounds like it might be slow. If you have a way of re-initializing the character (and any enemies, etc) without re-loading the entire level, that might be faster, and would mean you don’t have to track level state separately at all.

I’ve got a similar question here Reset level but not reset variables - Blueprint - Unreal Engine Forums - essentially I followed your advice but I’m still having an issue. I’m sure i’m doing something silly wrong!

Put the variables under Game Instance
then on your blueprints, cast to Game Instance to update them.
Game Instance is the only one that persists through level changes etc, until the game closes, so at some point if the information is important, save it in a save game using the method documented in the wiki.

THANKS BRO!!! i wish i learned about game instances a long time ago

How would your reset txt widgets (coins collected) on play button

How would I reset text variables on button pressed. I have open level connected to PLAY button. Do I need to put something before or after. In my button pressed I can get coin widget text 00 node but how do i tell it to reset to 00. Right now is going trough game instance which records how many coins I have collected. The coins get stored inside Game Instance in COIN BANK.