I’d like to pause the game when it’s not in focus by the player. For example alt-tabbing or minimizing would trigger a function that stops the time until the window is back in focus.
How can this be achieved, preferably in BP? I can’t find a function that returns if window is in focus or not. Best idea I have is to have a transparent widget cover the screen and check if that is in focus. Any advice?
The console command t.IdleWhenNotForeground=1 will lower framerate and CPU usage when you’ve alt-tabbed out. You can then maybe use frame time to determine if you’re idling for a BP only solution.
Otherwise you can get a C++ function to detect lost focus, see this question for details.
Is it possible to get a bool out of this command? I’m having trouble implementing this method.
For anyone interested, after enable-ing this you can get the FPS logged by dividing the DeltaTime on the Tick event by 1. In order to do that you have to have the blueprint set as Tickable even when Paused if you want to pause/unpause on lost focus.
I guess no news on this huh.
So far the closest I got without going too deep, checking if mouse location is 0:0 Searching didn’t work out too well either, this is the best discussion about the problem I have found so far.
But seriously, a simple event or blueprint node for checking if the game is in focus or not would be very welcome - Okay, I bet they have enough on their plates as is but I would really appretiate something like that.