How to do Real-Time with Pause

I’m currently working on a feature for a potential real-time tactics game that requires the game to be “paused” without actually pausing the entire game, known as “Real-Time with Pause” or “Active Pause”. Players should still be able to move the camera, use the interface and menus, and give orders, and the game should react to that as normal. But the 3D world itself, all animations, AI behavior, actor movements, particles effects, physics simulations, should be completely frozen. I can’t use the normal Pause Game node obviously, as I still need a way to pause the entire game, except for a pause menu.

I did some research and found I could use time dilation, but the log will show a warning that the value can only be between 0.0001 and 20 and will be capped. While at 0.0001 everything seems to be frozen, this is obviously not the case; everything still moves but very very slowly. In principle I could live with that limitation, but I would prefer to completely stop “time”. Is there a way to do this properly?

Setting Custom Time Dilation on an actor does work, even with particle systems, but not physics (which I assume is why Global Time Dilation cannot be set to 0). So if I can set Custom Time Dilation on all actors that need to stop moving and perhaps freeze the AI execution, how can I ensure that physics bodies too are “frozen”?

You can set the game to Paused but set specific actors and objects to Tick While Paused so they will continue on as if they were not paused.

I don’t believe I can do that, first because the game still needs to be paused normally as usual, and second because it seems to have limitations (which I don’t know what they are).

I don’t know, but maybe I could create a pool that collects all active objects in the world that should be frozen when paused, and set their Custom Time Dilation to 0, freeze the AI Behavior Trees, and (somehow) “freeze” the physics simulation of every rigid body. I just don’t think it would be very efficient when there are hundreds of actors in the world that have to be (un)frozen. This would include all vegetation, destructible objects, and more.

Another way might be to call “Set Tickable when Paused” on actors that should still work when using Active Pause, and make sure it is set to false when pausing normally. However, I would still like to know what the limitations are for Tick while paused to make sure it works for me.

I tried to enable tick while paused, but it seems to also pause the rendering as I can only see whether objects have moved after unpausing, and motion blur and temporal AA are also frozen.

I’m digging through the source code of the Set Game Paused function to see if I can build my own pause system, though if anyone has any pointers that would be helpful too.

EDIT: I just discovered that World Settings has settings for min and max time dilation. Indeed, setting the min to 0 will cause a NaN velocity error with physics bodies (and only if actors are simulating physics). I tried setting it to the absolute lowest value possible before it’s rounded down (0.000001) and pretty much every animated object freezes (their transform doesn’t seem to change, even if they are moving very fast), but physics bodies still have some velocity (sometimes quite high, like 0.1 UU/s).

I could use time dilation with that value, but then I need a separate method to freeze physics bodies. Is there an efficient way to simply “freeze” all of them in a level without losing their velocity?

Set-Tim-Dilation doesn’t work reliably for all Physics-Movement IIRC.
Is there a solution where Time Dilation is set high for camera / menus…
Slomo console-command is set low for everything else. Just a guess!