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_controlfolder to your project'saddonsfolder. - From editor toolbar, go to Project > Project Settings, then in Plugins tab activate TimeControl plugin.
-
Setup global clocks
The plugin provides a default
ClockControllerautoload scene located inres://addons/time_control/time_control.tscnwhich gives you access to the followingGlobalClockfrom 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
Clocknodes are automatically registered to their parentClockControllernode, which keeps track of all registered clocks.To customize this scene and the registered global clocks, see Customize
ClockControllerautoload scene.
-
Setup a
TimelineAdd a
Timelinenode to your scene, and add aClockConfigurationresource to theglobal_clock_configurationfield.Example: If the
Timelineis on your player scene, set theplayer_clock.tresresource (used on the PLAYERGlobalClock) in theglobal_clock_configurationfield.
-
Use the
Timelinenode 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
ClockControllerextends 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_scaleby the parent clocktime_scale -
BlendModeEnum.Additive
Adds the current clocktime_scaleto 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 aGlobalClockwith theglobal_clock_configurationsetting. -
ModeEnum.Local
Default value
The Timeline will target aClocknode with thelocal_clocksetting.
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.tscnanywhere 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_pathwith 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