---
title: "Control an effect's playback from code in Godot 4"
description: "Pause, slow down, scrub or sync a flipbook effect from GDScript in Godot 4 with speed_scale, Sprite3D frame or the clip time of a wired scene."
canonical: https://appliedmanifold.com/guides/godot-drive-effect-from-code/
site: "Applied Manifold: The spatial compute cloud for 3D reality"
---

1.  [Home](https://appliedmanifold.com/)
2.  [Guides](https://appliedmanifold.com/guides/)
3.  Drive an effect from code

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.

[Get Free API Key](https://console.appliedmanifold.com/sign-in?next=/api-keys) [See the examples →](https://appliedmanifold.com/docs/pyrofx/examples/)

-   **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](/bakes/fireball/poster.webp)

Fireball, 9.4 x 13.4 m, compiled with Spatial Compiler. [Spec →](https://appliedmanifold.com/docs/pyrofx/examples/#ex-fireball)

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](/bakes/smoke_column/poster.webp)

Smoke column, 8.2 x 9.9 m, compiled with Spatial Compiler. [Spec →](https://appliedmanifold.com/docs/pyrofx/examples/#ex-smoke_column)

05 // RELATED

## Related pages

-   [One-shot explosion Godot 4Build a GPUParticles3D explosion in Godot 4 that plays once and frees itself, by hand or from a wired fireball scene.](https://appliedmanifold.com/guides/godot-one-shot-explosion/)
-   [Explosion sound and shake Godot 4Fire an explosion, its 3D sound and a decaying camera shake together in Godot 4, with the sound delayed by distance.](https://appliedmanifold.com/guides/godot-explosion-sound-shake/)
-   [Godot fireball Godot 4A fireball that bursts from the ground and rolls upward in 3.7 seconds, dropped into a Godot 4 scene by your agent.](https://appliedmanifold.com/effects/godot-fireball/)
-   [Loop vs one-shotLooping effects repeat until stopped and one-shot effects play once and fade out, and each needs its own frames and settings.](https://appliedmanifold.com/learn/loop-vs-one-shot/)
-   [Play an explosion once three.jsPlay an explosion sprite sheet once in three.js, then remove the sprite and free its material and texture.](https://appliedmanifold.com/guides/threejs-play-once/)
-   [Bake and wireCall `bake` with a `.pyro.toml` spec and an output folder, then `wire` to write a Godot 4 scene with the six-way shader. `check`, `schema` and `sweep` support the loop.](https://appliedmanifold.com/docs/pyrofx/bake-and-wire/)

[All pages in Guides →](https://appliedmanifold.com/guides/)

[← Particle performance](https://appliedmanifold.com/guides/godot-particle-performance/)[Import a sprite sheet →](https://appliedmanifold.com/guides/godot-import-sprite-sheet/)

06 // FAQ

## Playback control questions

[All questions →](https://appliedmanifold.com/faq/)

**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.

[Get Free API Key](https://console.appliedmanifold.com/sign-in?next=/api-keys) [Bake and wire →](https://appliedmanifold.com/docs/pyrofx/bake-and-wire/)

[All effects, guides and explainers →](https://appliedmanifold.com/effects/)
