Godot Time Control
by zekogamestudio
Godot Time Control Plugin
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.
Compatibility
Godot 4.2+
Documentation
Installation
- 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.
Basic setup
-
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
Resources
ClockConfiguration
Resource representing a clock.
Properties
key
: String
The clock identifier key.
Nodes
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
local_time_scale
: float
The current clock time scale. Set this property to modify the clock time scale.
parent_clock_configuration
: ClockConfiguration
Optional
Assign a ClockConfiguration
resource as a parent clock if needed.
parent_blend_mode
: BlendModeEnum
-
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
get_time_scale()
-> float:
Returns the calculated time scale based on the local_time_scale
and the parent clock time scale.
GlobalClock
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.
Timeline
Add this node anywhere in your scene to access a Clock
or a GlobalClock
time scale.
Properties
mode
: ModeEnum
-
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.
time_scale
: float
Returns the target clock calculated time scale.
local_clock
: Clock
Assign a Clock
node. Works with ModeEnum.Local
global_clock_configuration
: ClockConfiguration
Assign a global ClockConfiguration
resource. Works with `ModeEnum.Global
ClockController
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
has_clock(clock_configuration: ClockConfiguration) -> bool
Returns true
or false
if the GlobalClock
matching the clock_configuration
is registered.
get_clock(clock_configuration: ClockConfiguration) -> GlobalClock
Returns the registered GlobalClock
from the clock_configuration
add_clock(clock_configuration: ClockConfiguration) -> GlobalClock
Registers and returns the new GlobalClock
remove_clock(clock_configuration: ClockConfiguration) -> void
Removes a GlobalClock
Customization
Change the ClockController
autoload scene
- 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
Examples
Check out the demo scene res://addons/time_control/demo/demo.tscn
Download
Support
If you need help or have questions about this plugin, please contact the author.
Contact Author