Action System Clock

v1.0

Juicy Actions includes an internal Clock System called the Action System Clock (ActionSystemClock). This clock is a lightweight, global timing layer that all Juicy Actions — and all ActionExecutor instances — automatically use.

By default, the Action System Clock mirrors Unity's built-in Time values, but it can also:

  • apply pausing and local time scaling

  • be replaced by your own custom time source (such as Magic Time or another clock system)

  • provide consistent, deterministic time values for all Juicy Actions, regardless of scene setup

Key Features

Feature
Description

Singleton access

Use ActionSystemClock.Instance from anywhere.

Implements IClock

Works seamlessly with ActionExecutor, actions, and resolvers.

No scene setup required

Lazy-loaded on first use.

Pause and Resume control

Temporarily stop all delta-based actions without stopping Unity's time.

Local time scaling

Multiply or reduce perceived time progression for all actions.

Custom provider support

Replace the default Unity time provider with your own system (e.g. Magic Time).

How It Works

All Juicy Actions fetch their time and delta values through an interface called IClock.

When you run any action:

float deltaTime = Executor.Clock.DeltaTime;

The executor does not read from UnityEngine.Time.deltaTime directly. Instead, it reads from ActionSystemClock.Instance, which internally wraps a time provider. This provider can be:

  • the default Unity clock (Time.time, Time.deltaTime), or

  • a custom provider that you install (e.g. Magic Time, custom physics clock, etc.)

What the Clock Returns

Property
Description
Default Value

Time

The current time (seconds since startup).

UnityEngine.Time.time

UnscaledTime

Time ignoring Unity's Time.timeScale.

UnityEngine.Time.unscaledTime

DeltaTime

Time elapsed since the last frame. Affected by pause and local scale.

Time.deltaTime

UnscaledDeltaTime

Delta time ignoring all scaling or pausing.

Time.unscaledDeltaTime

TimeScale

Local multiplier applied to delta time (independent of Unity's).

1.0f

IsPaused

Whether the overlay pause layer is currently active.

false

By default, all of these values exactly mirror Unity's Time values. Modify them only if you want local control (for example, pausing an ActionExecutor while gameplay continues).

Some Actions will modify the timescale as well, automatically.

Modifying the Clock

Pause / Resume

Pause or resume all Juicy Actions globally:

ActionSystemClock.Instance.Pause();
ActionSystemClock.Instance.Resume();

When paused:

  • IsPaused becomes true.

  • DeltaTime returns 0.

  • Actions that depend on time progression (e.g. Move, Wait, Fade) will freeze in place until resumed.

Time Scaling

Adjust the clock's local time scale to slow down or speed up the action system:

ActionSystemClock.Instance.TimeScale = 0.5f;  // half speed
ActionSystemClock.Instance.TimeScale = 2.0f;  // double speed

This multiplies the clock's DeltaTime, allowing slow-motion or fast-forward effects independent of Unity's Time.timeScale.

Custom Clock Providers

Replace the base time source with your own implementation. Useful if your game has its own time system or uses a local time controller like Magic Time.

Technical Notes

Details
  • The clock is a pure C# singleton (private ActionSystemClock() { }), not a MonoBehaviour. It survives domain reloads through static re-initialization.

  • The clock automatically resets on domain reloads (via [RuntimeInitializeOnLoadMethod]).

  • All Juicy Actions and ActionExecutors obtain their timing from this clock through the centralized resolver system (ActionClock.Resolve).

  • You can create and register your own IClockResolver to plug in different clocks per target (e.g. Magic Time bridge).

Last updated

Was this helpful?