UNITY TIME.DELTATIME EXPLAINED: FRAMERATE INDEPENDENCE
Understand the mathematics behind delta time, why omitting it breaks gameplay across different refresh rates, and how to build smooth timers and bullet-time slow motion.
1. What is Time.deltaTime?
In game development, Time.deltaTime represents the exact duration in seconds that elapsed between the completion of the previous frame and the current frame.
Because computers and mobile devices render at fluctuating speeds depending on scene complexity and GPU thermal limits, frame times vary constantly:
- At 60 FPS, each frame takes approximately
1 / 60 = 0.0166 seconds. - At 30 FPS, each frame takes approximately
1 / 30 = 0.0333 seconds. - At 144 FPS, each frame takes approximately
1 / 144 = 0.0069 seconds.
2. What Happens Without Delta Time?
Suppose you write movement like this inside Update():
// ❌ BAD: Frame-rate dependent movement!
transform.Translate(Vector3.forward * 5f);
This moves the object 5 units every single frame.
The player on the high-refresh monitor will fly across the level nearly 5 times faster!
By multiplying speed by Time.deltaTime, the units change from units-per-frame to units-per-second:
// ✅ CORRECT: Framerate-independent movement (Moves exactly 5 units every second)
transform.Translate(Vector3.forward * speed * Time.deltaTime);
3. Time.timeScale and Slow Motion
Time.timeScale scales the speed at which virtual game time passes. You can use it to create instant pauses or dramatic slow-motion bullet-time effects:
using UnityEngine;
public class TimeController : MonoBehaviour
{
// Trigger slow motion (e.g. during a cinematic missile impact)
public void EnableSlowMotion(float scale = 0.2f)
{
Time.timeScale = scale;
// IMPORTANT: Adjust fixedDeltaTime proportionally so physics doesn't stutter!
Time.fixedDeltaTime = 0.02f * Time.timeScale;
}
public void ResetNormalTime()
{
Time.timeScale = 1.0f;
Time.fixedDeltaTime = 0.02f;
}
public void PauseGame()
{
Time.timeScale = 0f; // Freezes all Time.deltaTime movements and animations
}
}
💡 Pro-Tip: Unscaled Time for Pause Menus
When the game is paused (Time.timeScale = 0f), Time.deltaTime becomes 0. If your pause menu needs animated button glows or cursor transitions, use Time.unscaledDeltaTime so UI animations continue running smoothly while gameplay remains frozen.
Related Mathematics & Tools
Frequently Asked Questions
Rigidbody.AddForce(force, ForceMode.Force) inside FixedUpdate(), Unity's PhysX engine automatically integrates Time.fixedDeltaTime internally. Multiplying by delta time manually would apply double damping, making your forces far too weak.
Time.smoothDeltaTime provides an exponential moving average of recent frame durations. It is useful for smoothing out FPS readouts on developer debug overlays so numbers don't rapidly flicker on screen.