GUIDE // GODOT 4

How to control an effect's playback from code in Godot 4

Turn off the effect's own playback and set its time yourself every frame, from your own clock, a replay timeline or a slider. In Godot 4 you set frame on a Sprite3D or seek an AnimationPlayer. A wired Spatial Compiler scene takes its clip time in seconds, so one value pauses, slows or rewinds it.

  • Godot 4 Available
  • Unity Manual setup
  • Unreal Engine Manual setup
  • Roblox Studio Manual setup
  • three.js Available

A draft compile is from $0.05, and new accounts start with $5 of usage.

FIREBALLFINAL
First frame of the fireball bake
Fireball, 9.4 x 13.4 m, compiled with Spatial Compiler. Spec →

01 // WHY

When the effect should not keep its own time

  • Slow motion and pause menus that should freeze the fire mid-flicker.
  • Replays and kill cams that scrub backward and forward.
  • Multiplayer, where every client should show the same frame of the same explosion.
  • Cutscenes timed to an AnimationPlayer track.

02 // HOW TO

Drive a wired effect from a clock

  1. Ask your agent to compile the effect and wire it into your project, then instance the scene where it plays.
  2. In _ready(), set autoplay = false on the effect so it stops advancing on its own.
  3. Keep your own clock, scaled by whatever sets your playback speed.
  4. Each frame, write the clock to time_s, the clip time in seconds.
  5. To rewind, lower the clock. The effect shows the frame for that time.
replay_fx.gd
extends Node3D

@onready var fx = $Fireball  # the scene wire wrote
var clock := 0.0
var rate := 1.0  # 0.25 for slow motion, 0 to pause, -1 to rewind

func _ready() -> void:
	fx.autoplay = false

func _process(delta: float) -> void:
	clock = maxf(clock + delta * rate, 0.0)
	fx.time_s = clock

In multiplayer, set clock from the server time of the event instead of adding delta, so late joiners see the explosion at the right moment.

03 // BY HAND

The same control on Godot's own nodes

  • Sprite3D with Hframes and Vframes: set frame from your clock, int(clock * fps) % frame_count for a loop.
  • AnimatedSprite3D: call pause() and set frame and frame_progress, or change speed_scale.
  • AnimationPlayer: call seek(clock, true) to jump to a time and update at once.
  • GPUParticles3D: speed_scale slows or pauses the simulation, but it cannot run backward. Use a flipbook node for anything you need to rewind.

04 // REAL OUTPUT

Clips worth scrubbing

SMOKE_COLUMNFINAL
First frame of the smoke_column bake
Smoke column, 8.2 x 9.9 m, compiled with Spatial Compiler. Spec →

06 // FAQ

Playback control questions

All questions →

README.GODOT_DRIVE_EFFECT_FROM_CODE
How do I change animation speed from code in Godot?

Set speed_scale on AnimatedSprite3D, AnimationPlayer or GPUParticles3D or multiply delta when advancing time_s on a wired Spatial Compiler scene.

Should I use AnimationPlayer or AnimatedSprite3D for a flipbook in Godot?

Use AnimatedSprite3D for a flipbook that plays on its own and AnimationPlayer keying Sprite3D frames when syncing with cutscene tracks.

Why is my AnimatedSprite3D not playing in Godot?

No animation is started; turn on Autoplay on Load or call play() in _ready() and confirm speed_scale is above 0.

How do I emit particles from code in Godot?

Set emitting to true on GPUParticles3D or call restart() to fire a One Shot emitter again after moving the node.

Why is my GPUParticles3D finished signal not firing?

The finished signal fires only when One Shot is enabled after the last particle dies; a looping emitter never sends it.

Compile your first effect

You pay per compile and see the price before it runs. New accounts start with $5 of usage.

All effects, guides and explainers →