What is Time.deltaTime and how does it work?
Source: Dev.to

What is Time.deltaTime?
To understand Time.deltaTime, you first need to know what the Update() method is.
Update() is Unity’s main player‑loop method and is called every frame. Anything you place inside Update() runs each frame—commonly, character movement code.
If you write code that moves a character 1 unit when a button is pressed, the character will move a different distance on machines with different frame rates. The faster the machine, the more times Update() runs per second, and the farther the character travels.
The Real Problem: FPS
The root cause is Frames Per Second (FPS).
- Higher FPS →
Update()is called more often → character moves more times per second → faster movement. - Lower FPS →
Update()is called fewer times per second → slower movement.
Time.deltaTime solves this by providing the time (in seconds) elapsed since the last frame. Multiplying movement by Time.deltaTime converts per‑frame movement into per‑second movement, ensuring consistent behavior across different hardware.
How does it work?
Example 1: Without Time.deltaTime
| Machine | FPS | Movement per frame | Movement per second |
|---|---|---|---|
| Slow PC | 60 | 1 unit | 60 × 1 = 60 units |
| Fast PC | 120 | 1 unit | 120 × 1 = 120 units |
Result: Faster machines move the character faster — undesirable.
Example 2: With Time.deltaTime
| Machine | FPS | Time.deltaTime (s) | Movement per frame (1 × deltaTime) | Movement after 1 s |
|---|---|---|---|---|
| Slow PC | 60 | ≈ 0.01666 | 0.01666 units | 0.01666 × 60 = 1 unit |
| Fast PC | 120 | ≈ 0.00833 | 0.00833 units | 0.00833 × 120 = 1 unit |
Result: Consistent character movement regardless of FPS.
How to use it
Simply multiply any per‑frame value (e.g., speed) by Time.deltaTime inside Update():
// Move forward at 1 unit per second
transform.Translate(Vector3.forward * 1f * Time.deltaTime);
// Or using a custom speed variable
transform.position += movementSpeed * Time.deltaTime * transform.forward;
Key Takeaway
When performing operations in Update() that should be frame‑rate independent, always use Time.deltaTime. Avoid time‑based movement without it unless you intentionally want behavior to vary with the machine’s performance.