

On the faster machine, each movement would happen every hundredth of a second, so the deltaTime would be. On the slower machine mentioned above, movement would happen 10 times every second, or at every one tenth (.1) seconds. When added to movement calculations in your code, it can help two machines offer similar movement experience in the game even if they are operating a completely different frame rates. Although this is not a constant value, it can be used to help normalize what is displayed. deltaTime is the time between the previous frames. To help normalize the speed of movement across systems that might vary in speed, you can use the Unity function ltaTime. In Unity, the movement of your character or game object is likely to be contained in code controlled within the Update method. As the Figure 2 shows, going 50 units at a speed of 1 unit per frame would take the slow machine 5 seconds whereas the fast machine could get there in just a half second.įigure 2: Making a Game Fair by Using ltaTime That’s not good and would quickly become a bad experience for the person on the slow machine. If the two players were racing to a location in the game, the fast machine would invariably win. If these two machines were being used to play a game against each other, the faster machine would display ten moves for every one move on the slower machine. This is illustrated in Figure 1.įigure 1: Performance differences between two machines On a machine that displays 10 frames per second, you’d only move 10 units. With a game, if you move a character one unit for each frame, on a machine that can display 100 frames per second, you’d move 100 units.

Slower machines tend to be able to display fewer frames per second. On faster machines, more frames can be displayed in any given second. This creates the animation and the overall action in the game.

You would not want the person with the faster machine to have an advantage!Ĭomputer displays operate by showing frames like a movie. This is most important when you are in a multi-player game. Regardless of the machine, you would like to see similar action on the screen when you play. Older systems tend to operate more slowly when playing games. A modern gaming machine will have a high-speed processor that can crank out a lot of power. A phone and a desktop computer often have very different processors. Additionally, you want the game to respond similarly regardless of the hardware you are using. When you play a game, you want it to be responsive.
