Is there a simple way to pause the game for a short time then automatically unpause it?

In my game I’d like it to freeze for a few frames when the player gets hit. I can think of a harder way to do it(Using an interface to stop everything that moves), but it would get very tedious and annoying over time so I’d rather avoid it if there’s something similar. Can anyone think of anything?

try GlobalTimeDilation

for a very simple example,

OnHit->SetTimerDilation(0.5)->RetriggerableDelay->SetTimerDilation(1)

At first it seemed like that wouldn’t quite work, but by setting the dilation to 0.01 and setting a timer for 0.003 seconds that works pretty well. Thanks.

Just as a “good thing to know”, is that timers and delays you use in Blueprint depend on game tick too, not just the delta. If a tick takes longer then the time you set inside them, then they will also take longer to trigger.

For example, if the game plays at 60 FPS, that means each tick takes around 16.67ms. If you have a timer on loop set to 0.001 (1ms), the timer will not get triggered 1 time each ms, but instead, each 16.67ms, it will get triggered 16-17 times at once, one after the other with no gap between them. Then next tick, will will trigger another batch of 16-17 executions.

That is why when you call “Set Timer by Event” / “Set Timer by Function Name” you have that “Max Once Per Frame” toggle, to avoid those extra executions for each tick/frame.

For your example, if the game runs at 60 fps, then your timer will actually take 16.67 ms to run, not 3 ms. Any value between 1-16ms (0.001-0.016), will take the same amount before it triggers.

If the game runs at 120, then any value between 0-8ms, will take the same amount 8.33ms before it gets triggered.

So at 60fps, your dilation will get back to 1 after ~16.67ms. If the game runs at 120 fps, your dilation will get back to 1 after ~8.33ms.

For your timer to run at the 3ms you wanted, the game has to run at ~334 FPS.

I don’t think this quite applies. I wanted it to run for 300 irl ms, not 3, and that’s what it’s doing… And I did notice a visible difference between 0.003 and 0.002

That was more as general “good to know”, and more specifically for looping instructions, and maybe how smooth an animation would look like for example, then what you would expect. But at the same time, those batch execution will use more CPU power for nothing.

For example, if you play at 60 FPS, and you set your timer 0.001, to move a piece on the map by 1 cm, then each ~16.67 ms, it will be moved 16-17 cm at once basically, and not 1 cm each 1 ms.

If your game runs at 120 FPS, then the timer will trigger more frequent, but still, it will move the piece each 8.34 ms, by 8-9 cm at once.

For this a Timeline would be better, but that was just a practical example what happens in the background.

300 ms for a timer means 0.3, not 0.003 as you mentioned in the previews comment.

Between 0.003 (3ms) and 0.002 (2ms) you can not notice a difference not in real life (for human eye) or in UE, as it will always take longer then that due to tick I mentioned.

BUT, between 300ms, and 200ms, yeah, you can perceive that difference. Even between 50 and 100.

Maybe you have a delay for when it starts, as 0.003 it is 3ms, not 300. You could check that too, to be sure it is what you wanted, and not get confused later when you look at the nodes.

For this, it will run after at most 317 ms even at 60 FPS, so yeah, the player will not notice a difference between if it happens to run at 300 or 317 ms.

If you want more details, we can move to private messages, as they will be offtopic, so we don’t make this post larger.