Get time the game has not been running

I tried to get time the game has not been running.


So First, I get the time when the player game quit

Next, If record is exist → currently time - exit time through I tried to get the time the game has not been running

But It’s not working :frowning:

image

You need Saving and Loading Your Game | Unreal Engine 4.27 Documentation To store variables between game sessions.

I just implemented it :smiley:
However, when I do (current time-end time), the result is constantly changing.
Is it possible to make that result value fixed?

Share your new blueprint implementation and lets see if we can help.

… but taking a guess: what you need is to split the time struct and do the math yourself… something like

((CurrentHour * 60 + CurrentMinute) * 60 + CurrentSecond) - ((ExitHour*60 + ExitMinute) * 60 + ExitSecond)

After you get the total seconds between sessions, turn them back to h : min : sec

Youll need to be creative to know when its passed midnight.

Nothing change between current and question blueprint image

Just added the function that variable save and load :slight_smile:
2552

The node of “Now” is keep changing so I think I must be do something :sweat:

Read this :point_up:

When the game is closed, all variables are erased. You need to create a save and store the variable there, then load it when the game begins.

Where is that in your blueprint?


I already made this function :smiley:
The save and load variable function works fine.

The current problem is that the end time is fixed so that doesn’t matter, but the current time fetched from the “Now” node is constantly changing. :frowning:

Oh I fixed!


It was very simple!
Just I used Do Once node
Thanks for all your advice and aswer :smiley:

What? :expressionless:

Just use BeginPlay and delete both tick and DoOnce.