We will create a frame-independent world replace as a result of we are able to get the present time in milliseconds originally of every body replace. Which means we are able to calculate how a lot actual time has handed for the reason that final body replace and recalculate the brand new state of the world (physics, animation, VFX, movement, lighting, UI, and so on.). Due to this fact, if 15 milliseconds have handed for the reason that final body, we all know that we have now superior 15 milliseconds within the state of the world. If we delete a bunch of frames and discover that 160 milliseconds have handed for the reason that final body replace, we are able to nonetheless advance the state of the world by 160 milliseconds to maintain time fixed.
This scales completely fantastic when rising the body charge. As a result of we make extra frames, the body time decreases and we get increased constancy as a result of we see extra body updates than earlier than. Because the world state progresses in actual time, including extra frames makes every part really feel higher at little to no price. However what occurs when the other scenario happens? As a substitute of including extra frames per second, let’s take into account the scenario the place the {hardware} is confused, inflicting the body time to extend and the body charge to lower.
The issues come up from having to research and handle inputs regarding the world state. What occurs between body updates is successfully atomic: if gamers press a button after which launch it between body updates, there isn’t a method for the sport to register that each occasions occurred whereas the world state was updating. When a body refresh happens, we are able to solely register a button enter as on or off, irrespective of how a lot time has handed between frames. This could trigger lots of frustration when the sport drops frames!
Think about an enemy throws a brief fuze grenade in the midst of a big, visually explosive battle. The sport drops lots of frames as a result of every part on the display screen. On the following body replace, half a second later, the sport calculates that the timer on the grenade fuse has expired and that the grenade has already exploded, killing the participant who has not moved as a result of there was no method for the participant to see the grenade coming and dodge it in response to it. For the participant, the sport froze for half a second after which she died.
We will keep away from the issue of body loss if the world state is tied to the body charge. When the participant is assured to see each body, they are going to nonetheless be capable to see each sport occasion, even when the sport’s body charge drops to 30, 20, 15, and even 10 fps. The participant at all times has the chance to react to sport occasions by blocking the world replace on the body charge. This is the reason many video games that pushed {hardware} limitations and nonetheless selected to lock a decrease body charge (e.g. 30fps) at launch most popular to lock the world state on the body charge; It was to guard in opposition to conditions the place the {hardware} was pushed to its limits and the builders didn’t need to add extra frustration to an already traumatic scenario.
(Be a part of us on Discord) I (Assist us on Patreon)
Do you could have a burning query you need answered?
