1. Using Juicy Actions Clock
v1.0
We will be using the Juicy Actions Clock for this project. The clock is available at runtime.
Handling Character Motion
Open ThirdPersonController, and make the following changes:
Add
using MagicPigGames.JuicyActions;to the top of the class.Add a
DeltaTimeproperty:private float DeltaTime => JuicyActionsClock.Instance.DeltaTime;Replace all
Time.deltaTimecalls withDeltaTime.Find the
Move()method, and add to theSmoothDampAnglesignature:, 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