Easy to use time control for godot.
Define multiple clocks to use different time scales on your nodes.
This plugin heavily inspired by CyberSys/ChronosTimeControl Unity asset.
Godot 4.2+
- Download the latest release.
- Extract the
addons/time_control
folder to your project'saddons
folder. - From editor toolbar, go to Project > Project Settings, then in Plugins tab activate TimeControl plugin.
-
Setup global clocks
The plugin provides a default
ClockController
autoload scene located inres://addons/time_control/time_control.tscn
which gives you access to the followingGlobalClock
from anywhere in your project :- The WORLD clock, the main clock. The other clocks are parented to this clock
- The PLAYER clock, manages the player time scale
- The ENEMY clock, manages the enemies time scale
- The ENVIRONMENT clock, manages the environment time scale on objects such as ambiant particle effects or animated props
These
Clock
nodes are automatically registered to their parentClockController
node, which keeps track of all registered clocks.To customize this scene and the registered global clocks, see Customize
ClockController
autoload scene.
-
Setup a
Timeline
Add a
Timeline
node to your scene, and add aClockConfiguration
resource to theglobal_clock_configuration
field.Example: If the
Timeline
is on your player scene, set theplayer_clock.tres
resource (used on the PLAYERGlobalClock
) in theglobal_clock_configuration
field.
-
Use the
Timeline
node in your script.extends CharacterBody2D const Timeline = preload("res://addons/time_control/timeline.gd") const SPEED = 300 @export var timeline: Timeline func _physics_process(delta: float) -> void: var direction = Vector2.ONE velocity = direction * SPEED * timeline.time_scale move_and_slide()
-
Change the time scale from anywhere using
ClockController
extends Node const ClockConfiguration = preload("res://addons/time_control/clock_configuration.gd") @export var clock_configuration: ClockConfiguration func _process(delta: float) -> void: ClockController.get_clock(clock_configuration).local_time_scale = 0.5
or
extends Node func _process(delta: float) -> void: ClockController.get_clock_by_key("PLAYER").local_time_scale = 0.5
Resource representing a clock.
This Node calculates an indenpendant time scale based on the local_time_scale
.
If the clock has a parent, the parent time scale is blended with the local_time_scale
.
Properties
The current clock time scale. Set this property to modify the clock time scale.
Optional
Assign a ClockConfiguration
resource as a parent clock if needed.
-
BlendModeEnum.Multiplicative
Default value
Multiply the current clocktime_scale
by the parent clocktime_scale
-
BlendModeEnum.Additive
Adds the current clocktime_scale
to the parent clocktime_scale
Methods
Returns the calculated time scale based on the local_time_scale
and the parent clock time scale.
Inherits Clock
You can retrieve a GlobalClock
node from anywhere with the ClockController
autoload.
The ClockConfiguration
resource parameter is required.
If you need to access the GlobalClock
time scale only, we recommend adding a Timeline
node to your scene.
Add this node anywhere in your scene to access a Clock
or a GlobalClock
time scale.
Properties
-
ModeEnum.Global
Default value
The Timeline will target aGlobalClock
with theglobal_clock_configuration
setting. -
ModeEnum.Local
Default value
The Timeline will target aClock
node with thelocal_clock
setting.
Returns the target clock calculated time scale.
Assign a Clock
node. Works with ModeEnum.Local
Assign a global ClockConfiguration
resource. Works with `ModeEnum.Global
This node keeps track of all GlobalClock
in your project and provides methods to get / add / remove them from anywhere in your project at runtime.
Methods
Returns true
or false
if the GlobalClock
matching the clock_configuration
is registered.
Returns the registered GlobalClock
from the clock_configuration
Registers and returns the new GlobalClock
Removes a GlobalClock
- Copy/paste the
res://addons/time_control/time_control.tscn
anywhere in your project - Open the copied scene and apply changes (ie: add / remove global clocks)
- Go to Project > Project Settings > Addons > Time Control and modify the
autoload_path
with your new scene path.
Example:res://scenes/time_control.tscn
- Disable/Enable the plugin or reload project to apply changes
Check out the demo scene res://addons/time_control/demo/demo.tscn