Advertisement

Avoiding Framerate Dependency.

Started by January 16, 2021 10:39 PM
2 comments, last by frob 3 years, 10 months ago

What are some of the best ways I can keep my game from being framerate dependent? I know it's not a good thing to do, but I have no idea any way to avoid the issue.

Conceptually, don't have a single loop doing both game-progress computing and rendering.

Instead, have 2 loops. One loop that updates the game data, and one that does rendering. A great article about it is

https://www.gafferongames.com/post/fix_your_timestep/

Advertisement

If you are using an existing game engine like Unity or Unreal, the engine provides it as an option out of the box.

In Unity this can mean functions like Update() and FixedUpdate(), with Update() being run every frame (usually), and FixedUpdate() run at regular intervals regardless of framerate. In Unreal this can mean Tick() and enabling/disabling the Tick Substepping options and tick rate options; by default it runs every frame but can be adjusted to run at frequencies better suited to you, either with substeps that are smaller, or custom tick rates longer/slower than a frame. Or it can mean implementing something yourself that adjusts how often they are run.

This topic is closed to new replies.

Advertisement