Course contentsShow
← Unity Game Development
Lesson 714 of 82810. VFX and Post-ProcessingFree lesson

Developing Time Dilation Effects for Combat

You will manipulate the global Time.timeScale property to create hit-stop and slow-motion effects that emphasize powerful player actions.

In this lesson, you will learn how to manipulate the global Time.timeScale property to create high-impact "hit-stop" and slow-motion effects that give your combat system a professional, weighty feel.

The Power of Temporal Manipulation

When a player lands a powerful blow, visual feedback alone isn't always enough to sell the impact. By momentarily pausing or slowing down the game world, you provide the player’s brain with a fraction of a second to "feel" the connection, transforming a standard animation into a visceral combat experience.

Implementing Hit-Stop

"Hit-stop" (or freeze-frame) occurs when you set Time.timeScale to 0 for a few frames upon impact. This creates a jarring halt that simulates the resistance of an object being struck. After the duration expires, you reset the timescale to 1 to resume the action.

public void TriggerHitStop(float duration)
{
    Time.timeScale = 0f;
    StartCoroutine(ResumeTime(duration));
}

private IEnumerator ResumeTime(float duration)
{
    // Use real-time waiting since Time.timeScale is 0
    yield return new WaitForSecondsRealtime(duration);
    Time.timeScale = 1f;
}

Implementing Slow-Motion

For more dramatic moments, like a "perfect parry" or a low-health surge, you can gradually interpolate Time.timeScale to a lower value (e.g., 0.3f). Because Time.deltaTime is tied to Time.timeScale, your physics and character movement will automatically sync with the visual slowdown.

Pro-tip: When scaling time, always ensure your UI animations or cooldown timers use Time.unscaledDeltaTime if you want them to remain responsive and ticking at normal speed while the gameplay world slows down. If you want the entire game, including menus, to slow down, Time.deltaTime is your default preference.

By combining short bursts of freeze-frame for impact and subtle slow-motion for cinematic flair, you turn static combat mechanics into a dynamic, rhythmic spectacle.

Key Takeaway: Manipulating Time.timeScale provides a powerful tool to emphasize combat impact, but always remember to use WaitForSecondsRealtime and Time.unscaledDeltaTime to keep essential systems functional during temporal shifts.