1. Using Juicy Actions Clock

v1.0

We will be using the Juicy Actions Clock for this project. The clock is available at runtime.

Since we are using a pre-made scene, we need to modify existing code. Please be aware that re-importing the Starter Assets - ThirdPerson package risks overwriting the changes we are about to make.

Handling Character Motion

Open ThirdPersonController, and make the following changes:

  1. Add using MagicPigGames.JuicyActions; to the top of the class.

  2. Add a DeltaTime property:

    private float DeltaTime => JuicyActionsClock.Instance.DeltaTime;
  3. Replace all Time.deltaTime calls with DeltaTime.

  4. Find the Move() method, and add to the SmoothDampAngle signature: , Mathf.Infinity, DeltaTime β€” Here's the full line:

    float rotation = Mathf.SmoothDampAngle(transform.eulerAngles.y, _targetRotation, ref _rotationVelocity,
                        RotationSmoothTime, Mathf.Infinity, DeltaTime);

Next, we want to ensure the "Mouse Look" rotation doesn't occur when the game is paused, or the timeScale = 0. Other than that, it's fine to allow full motion at the expected speed.

Find the CameraRotation() method, and add at the top of the method:

if (DeltaTime <= 0f || JuicyActionsClock.Instance.IsPaused) return;

Press play: You should see no motion on the player character or the camera.

Handling Animation

Create a new class, AnimatorTimeScaler (see example below). This simple class will set the animator.speed to match the Juicy Actions Clock TimeScale. When the time slows down, animations will slow down. When time stops, so will the animations.

This should be attached to the PlayerArmature, and Spitter. Don't forget to save the prefabs.

Last updated