Menu
CoddyTech

Recap: Bullet Time

Part of the Building Real Games section of Coddy's Unity journey. Lesson 36 of 56.

challenge icon

Challenge

Medium

Give the game bullet time, powered by a focus meter. Write BulletTime.cs on the Game object. The Inspector sets slowScale (0.2), maxFocus (2), recharge (0.5) and focusBar, the filled Image at the top of the screen. Keep the meter in the float focus.

  • focus starts full, at maxFocus.
  • While Space is held and focus is above 0, the game runs at slowScale, with the physics step shrunk by the same factor from 0.02, and focus drains by 1 every real second, never below 0.
  • The rest of the time, the game runs at normal speed with a physics step of 0.02. An empty meter ends bullet time even while Space stays down.
  • While Space is not held, focus refills by recharge every real second, up to maxFocus.
  • Every frame, the bar's fillAmount is focus divided by maxFocus.

Press Play, hold Space and watch the rain, then Check.

Try it yourself

using UnityEngine;
using UnityEngine.UI;

public class BulletTime : MonoBehaviour
{
    public float slowScale = 0.2f;
    public float maxFocus = 2f;
    public float recharge = 0.5f;
    public Image focusBar;

    float focus;

    void Update()
    {
    }
}

All lessons in Building Real Games