Explaining deltaTime

The concept of ‘Delta Time’ took me the longest time to figure out. It’s a concept in computer programming that helps make sure that every user has the same experience regardless of the clockspeed of their machine. This is especially useful in game development, where you don’t want the player on an older machine being inherently worse than the player on a state-of-the-art machine.

I still have to think really hard when I explain it to someone but it’s basically like this:

Take one second of gameplay from your game and imagine it as a white picket fence.

Each fencepost represents a frame, a still image, so in a regular game your fence would have 30 posts. (30 fps)

If your computer is slower, there are less posts in your fence. This makes the space between the posts bigger. That space between the posts is the deltaTime.

So if you want your guy to move from A to B, and it takes 30 frames to get to B, players on 30fps will get there in one second, and players on 15fps get there in two seconds. Obviously unacceptable, especially in a multiplayer game.

So if you multiply the movement speed with the deltaTime (the gap between the frames), you ensure that every player always reaches point B in the same amount of time, regardless of how fast their computer is.

This is because when you run at a lower fps your deltaTime is LARGER, because the GAP between frames is larger, and so each movement gets multiplied with a LARGER number, which means your dude will move FASTER so he can keep up with the intended pace of the game.

Hope that helps.

Leave a Reply