I am working on a quiz/trivia game and it needs to be in windowed mode. I have it working just fine in windowed mode, but when you click and drag the window around the game pauses. This actually creates an exploit as you can do this while answering a question and it’ll pause the game. This gives you as much time as you want to answer the question without the timer running down. My question is how can I keep the game running if the player clicks and drags the game window? Also if this isn’t something that is possible, how can I detect this pausing/freezing so I can display an image to block the screen while they drag the window? I’ve done some searching but haven’t found anything that works yet.
You could try and use the System DateTime to check against an internal time keeper in your game.
If the DateTime on the system is out by to much in that instance, you could probably consider that the player has attempted to cheat by using that exploit.
You would need to be careful that any Pause states that are legitimate dont cause this to malfunction.
I dont know of a way to detect if the actual application is being moved about the screen. At least not in Blueprints.
AFAIK there is no easy way to go about achieving this easily. In the case of blueprints I think the only solution is to run an internal time keeping system like DevilsD suggests.
You can have a lastTime variable that polls the System datetime every single frame and reduce the ingame timer by (newTime - lastTime) every frame.
An alternative is just to get the DeltaTime and reduce the ingame timer by that amount every single frame. DeltaTime should behave nicely if the game suddenly stops updating.
These should suffice for the case where the player tabs out of the game and the update code halts, since you’d have a frame that took x amount of time to render, where x is the amount of time the game has been paused and the next frame either of these solutions would reduce the ingame timer by x + updateTime so the second the player tabs back into the game, the timer will run out.
You just need to make sure you handle the case where they press the button the SAME frame that they alt tab into the game.
This worked. I actually didn’t think about using System Time, it works now. Thanks for the help.