Fixing minimum allowable framerate using MaxDeltaTime

This is something that isn’t documented anywhere in the UE4 or UE5 docs that I can find, and there’s no option setting to configure it in the engine… presumably because it behaves badly with Network Replication. But it is still something that some developers may wish to have access to and it’s doable, so I want to make a note of it here since none of my forum searches revealed anything.

It is possible, in UE4, to specify a MaxDeltaTime value, which caps the maximum value the game engine ever reports for delta time. This has the consequence of setting a “minimum allowable framerate”; the game will run smoothly at all framerates above this target, but any time the game’s framerate falls below this target, rather than getting choppier/updating less frequently, the game itself will slow down to make sure that the same number of timesteps pass.

Most of the time, when you’d want this kind of behavior, it’s for physics reasons, and UE already supports physics substepping, so this has limited use. The one case where it’s very useful, however, is frame data; action and fighting games are often designed with a fixed framerate specifically because game logic demands that every frame of an animation must occur because gameplay logic is tied sequentially to them. If you have invulnerability on frame 8, and a hitbox on frame 10, you don’t want those to occur simultaneously because the game’s framerate dropped and both event calls were handled on the same frame in the game thread. You need one to occur 2 frames of animation before the other. This was my issue, and I wanted my game to never allow animations to play slower than 60 frames per second, but I also wanted the game to be allowed to run above 60FPS when possible.

This also has the advantage that during a lag spike, the game will temporarily slow down and resume from where it was, rather than resuming with the character in some unexpected state since a very large timestep suddenly occurred.

To accomplish this, go into DefaultEngine.ini and add the following lines

[/Script/Engine.GameEngine]
MaxDeltaTime=0.016666

Or whatever Delta Time cap you want to set (determined by 1/minframerate; 0.016666 is for 60FPS)

This will not work in PIE, but it WILL work in Standalone testing and packaged games (packaged games this line may need to be put in a different .ini, but whichever .ini in the end contains your game’s [/Script/Engine.Engine] settings)

Hopefully the next person who goes searching for this issue finds this post and it’s helpful to them, because I had to figure it out by borrowing tricks that UE3/UDK game modders were doing to manipulate released games in order to figure it out.

2 Likes