How to execute C++ timer even when the game is paused?
I'm currently programming a playtime tracker in C++ that supposedly keeps increasing even when paused, due to the playtime variable only shown in the pause menu. However when pausing the game through the character blueprint, the timer in the C++ code is also paused.
AFAIK, this was because Game Pause function pauses the global time dilation too, thus affecting the timer which is called using
Is there any workaround or alternative function for the timer? I avoiding Tick because the tracker requires precision down to 10 ms (0.01 s), which is faster than stable 60 FPS frametime, and can cause imprecision on slower frametimes (delta secs).
asked Mar 15 '19 at 12:16 PM in C++ Programming
The Hoodie Guy
This doesn't directly answer your question as stated — I'm not sure how to prevent the Timer Manager from being paused when the game is paused — but this is hopefully a solution for your needs.
Why not use UWorld::GetRealTimeSeconds() to store the real-world time when the game session starts, and call that function again whenever you need to update (and display) the session's elapsed time to the player?
Just do something like
...to update how long the session has been active. Your pause menu can use this updated variable to always display the current, accurate elapsed time.
(That example assumes you have a variable called 'SessionStartTimeSeconds' which you would set when the session starts, e.g. in some BeginPlay() function somewhere.)
Hope that makes sense. Good news is, it should be really easy to get working, even if my explanation is bad.
answered Mar 15 '19 at 05:21 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here