TExcelTAD
Home › Game Development Roadmap & Fundamentals › Pausing & Time Scale

Pausing & Time Scale

Once everything in your game moves by delta time, you get a powerful feature almost for free: time scale. Multiply dt by a factor before the game uses it and the whole world slows down (0.25), speeds up (2.0) or stops (0). Pausing, slow motion, "bullet time", hit-stop and fast-forward are all the same trick.

Scaled and unscaled time

Not everything should slow down. When the game is paused, the pause menu must still animate and respond to input. So a game keeps two clocks:

Clock Used by Paused at time scale 0?
scaled game time gameplay, physics, enemy AI, cooldowns, in-world animation yes
unscaled real time menus, UI tweens, input handling, network heartbeats, "press any key" blinking no
csharp · try it yourself
using System;

var clock = new GameClock();
string[] events = { "", "", "pause", "", "", "resume", "slowmo", "", "", "normal", "" };
double enemyX = 0;

foreach (string e in events)
{
    switch (e)
    {
        case "pause":  clock.TimeScale = 0;    break;
        case "resume": clock.TimeScale = 1;    break;
        case "slowmo": clock.TimeScale = 0.25; break;
        case "normal": clock.TimeScale = 1;    break;
    }
    clock.Tick(0.1);                  // every real frame is 100 ms here
    enemyX += 10 * clock.DeltaTime;   // gameplay uses SCALED time
    Console.WriteLine(
quot;{e,-7} scale={clock.TimeScale,4} game t={clock.GameTime:F3} real t={clock.RealTime:F1} enemy x={enemyX:F2}"); } class GameClock { public double TimeScale = 1; public double DeltaTime { get; private set; } // scaled public double UnscaledDeltaTime { get; private set; } // real public double GameTime { get; private set; } public double RealTime { get; private set; } public void Tick(double realDt) { UnscaledDeltaTime = realDt; DeltaTime = realDt * TimeScale; RealTime += UnscaledDeltaTime; GameTime += DeltaTime; } }
        scale=   1  game t=0.100  real t=0.1  enemy x=1.00
        scale=   1  game t=0.200  real t=0.2  enemy x=2.00
pause   scale=   0  game t=0.200  real t=0.3  enemy x=2.00
        scale=   0  game t=0.200  real t=0.4  enemy x=2.00
        scale=   0  game t=0.200  real t=0.5  enemy x=2.00
resume  scale=   1  game t=0.300  real t=0.6  enemy x=3.00
slowmo  scale=0.25  game t=0.325  real t=0.7  enemy x=3.25
        scale=0.25  game t=0.350  real t=0.8  enemy x=3.50
        scale=0.25  game t=0.375  real t=0.9  enemy x=3.75
normal  scale=   1  game t=0.475  real t=1.0  enemy x=4.75
        scale=   1  game t=0.575  real t=1.1  enemy x=5.75

While paused, real time keeps running (the menu stays alive) and game time stands still.

In the engines

Engine Pause / time scale Unscaled time and "runs while paused"
Unity Time.timeScale = 0f pauses; 0.5f is half speed Time.unscaledDeltaTime; UI animations can be set to unscaled time. At 0, FixedUpdate stops running and Update keeps running with Time.deltaTime == 0
Godot get_tree().paused = true; Engine.time_scale for slow motion each node's process_mode (PROCESS_MODE_ALWAYS, PROCESS_MODE_WHEN_PAUSED) decides whether it still runs
Unreal UGameplayStatics::SetGamePaused(this, true); UGameplayStatics::SetGlobalTimeDilation actors can tick while paused (SetTickableWhenPaused); per-actor CustomTimeDilation

Pause is also a game state

Setting the time scale to zero freezes motion, but it doesn't stop input from reaching gameplay. A paused player still shouldn't be able to fire. Treat "paused" as a state of the game (see State Machines) that changes which systems receive input, and use time scale only for what it is good at: freezing or slowing the simulation.

Hit-stop: tiny pauses that feel great

Fighting and action games freeze the game for a few frames when a big hit lands. The pause sells the impact. It is a time scale of 0 for a short real-time duration. Notice the timer counts down in unscaled time, otherwise it would never end:

csharp · try it yourself
using System;

double timeScale = 1;
int hitStopLeftMs = 0;                 // whole milliseconds keep the example exact
string[] frames = { "", "HIT", "", "", "", "", "" };
const int realDtMs = 16;               // about 60 FPS
double swordAngle = 0;

for (int i = 0; i < frames.Length; i++)
{
    if (frames[i] == "HIT") hitStopLeftMs = 48;            // freeze for 48 ms of REAL time

    timeScale = hitStopLeftMs > 0 ? 0 : 1;
    hitStopLeftMs = Math.Max(0, hitStopLeftMs - realDtMs); // counts down unscaled

    swordAngle += 600 * (realDtMs / 1000.0) * timeScale;   // the swing uses scaled time
    Console.WriteLine(
quot;frame {i}: {frames[i],-3} scale {timeScale} sword {swordAngle,4:F1}°"); }
frame 0:     scale 1  sword  9.6°
frame 1: HIT scale 0  sword  9.6°
frame 2:     scale 0  sword  9.6°
frame 3:     scale 0  sword  9.6°
frame 4:     scale 1  sword 19.2°
frame 5:     scale 1  sword 28.8°
frame 6:     scale 1  sword 38.4°

Three frozen frames, about 50 ms, are enough. Longer and it reads as lag; shorter and nobody notices.

Pitfalls

  • Dividing by dt. At time scale 0, dt is 0. Code that computes speed = distance / dt will divide by zero while paused. Guard it.
  • Timers on the wrong clock. A "game over in 3 s" timer on unscaled time keeps running in the pause menu; a UI fade on scaled time never finishes while paused.
  • Audio. Pausing the time scale doesn't pause sound. Pause or duck the music and sound effects explicitly (Unity's AudioListener.pause, Godot's audio buses or process_mode, Unreal's sound classes).
  • Physics. Changing the time scale changes how much simulated time passes, not the fixed step; very high time scales (fast-forward) can run many physics steps per frame. Cap it.

Test yourself

The game is paused with time scale 0. Which clock should the pause menu's animations use?

  1. Scaled game time
  2. Unscaled real time
  3. The physics step
  4. None; menus can't animate while paused

Why must a hit-stop timer count down in unscaled time?

  1. It is more accurate
  2. Scaled time is frozen during the hit-stop, so a scaled timer would never finish
  3. Unscaled time is faster
  4. To sync with audio

In Godot, what decides whether a node keeps processing while the tree is paused?

  1. Engine.time_scale
  2. The node's process_mode
  3. The node's name
  4. Its z_index