How to save a variable?

In Project Settings “Project - Maps and Modes” you can create a new GameInstance class. The GameInstance persists between levels until you quit the game.

Hello to finalize my project I need to recover the time of the level Map that is displayed through the Widget Class HUB. Once recovered I have to display it in the second level FinMenuLevel in the Class Widget FinMenuWidget. Since I change the level the variable is erased. Do you have a solution to save or recover the variable?

Thanks, I looked at the tutorial to try to better understand HTF do I? Use the GameInstance Object in Unreal Engine 4 - YouTube but I still can not do a getInstance → Cast to GameInstanceRunner → Timer. Can you teach me how to do?

To make my stopwatch I made the same one: Unreal Engine 4 Tutorial: Racing Timer/Stopwatch Tutorial - YouTube

Your custom GameInstance class has to be set in the Project Settings under Maps and Modes (Game Instance Class) then you should be able to get the GameInstance at any time.

I understand the use of the GameInstance, but I can not stop my timer and get it back to the next level.

Using a timeline to make a stopwatch is overkill anyway and not the purpose of a timeline. You should use a “SetTimerByEvent” or “SetTimerByFunctionName” and have it looping every second and you will have exactly the same behavior. When you want the Timer to stop you simply call “SetTimerByEvent” again but with a time of 0.0 and it will stop.