---
title: "Sync an explosion with sound and screen shake in Godot 4"
description: "Start the explosion, its AudioStreamPlayer3D and a decaying camera shake from one function in Godot 4, and delay the sound by distance for far blasts."
canonical: https://appliedmanifold.com/guides/godot-explosion-sound-shake/
site: "Applied Manifold: The spatial compute cloud for 3D reality"
---

1.  [Home](https://appliedmanifold.com/)
2.  [Guides](https://appliedmanifold.com/guides/)
3.  Explosion sound and shake

GUIDE // GODOT 4

# How to sync an explosion with sound and screen shake in Godot 4

Start the explosion, its sound and your camera shake from one function on the same frame, and let the shake peak at the flash and die out over about half a second. For blasts far from the camera, delay the sound by the distance divided by 343 meters per second, so it arrives after the flash as it would outdoors.

[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 // HOW TO

## One script for picture, sound and shake

1.  Make an explosion scene with the effect, an `AudioStreamPlayer3D` named Boom and `explosion.gd` on the root.
2.  Instance it at the blast point. `_ready()` starts the effect, plays the sound and sets the shake strength.
3.  The shake fades every frame and moves the camera with `h_offset` and `v_offset`, which leave the camera's real position alone.
4.  Scale the starting shake by distance to the camera, so a blast across the map barely nudges the view.

explosion.gd

```
extends Node3D

@onready var fx = $Fireball  # the scene wire wrote
@onready var boom: AudioStreamPlayer3D = $Boom
@onready var cam: Camera3D = get_viewport().get_camera_3d()
var t := 0.0
var shake := 0.0

func _ready() -> void:
	fx.autoplay = false
	var dist := cam.global_position.distance_to(global_position)
	shake = clampf(1.0 - dist / 60.0, 0.0, 1.0)
	get_tree().create_timer(dist / 343.0).timeout.connect(boom.play)

func _process(delta: float) -> void:
	t += delta
	fx.time_s = t
	shake = maxf(shake - delta * 2.0, 0.0)
	cam.h_offset = randf_range(-1.0, 1.0) * shake * 0.3
	cam.v_offset = randf_range(-1.0, 1.0) * shake * 0.3
```

Driving the effect's clock from the same `_process` as the shake keeps the two in step even when the frame rate dips. Free the node once the clip ends.

02 // TIMING

## Where the beats fall

The flash is the first thing the eye catches, so the shake should start at full strength on the first frame and the loudest part of the sound should sit there too. A sound file with silence at the start makes the blast feel late; trim it.

The fireball compile bursts from the ground and rolls upward for 3.7 seconds. The smoke column that follows lasts 5.0 seconds, so layering it a moment after the fireball carries the aftermath while the sound tails off.

03 // REAL OUTPUT

## The layers of one blast

A fireball, a ground impact and the smoke left behind.

**IMPACTFINAL**

![First frame of the impact bake](/bakes/impact/poster.webp)

Impact, 3.5 x 2.8 m, compiled with Spatial Compiler. [Spec →](https://appliedmanifold.com/docs/pyrofx/examples/#ex-impact)

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

04 // 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/)
-   [Drive an effect from code Godot 4Pause, slow, rewind or sync a flipbook effect from GDScript in Godot 4 by driving its clip time from your own clock.](https://appliedmanifold.com/guides/godot-drive-effect-from-code/)
-   [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/)
-   [Godot impact Godot 4A shell impact with a flash, thrown earth and smoke in 2 seconds, dropped into a Godot 4 scene by your agent.](https://appliedmanifold.com/effects/godot-impact/)
-   [Game VFXGame VFX are real-time effects such as fire, smoke, explosions and hits, built from particles, flipbooks, shaders and lights.](https://appliedmanifold.com/learn/game-vfx/)
-   [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/)

[← Import a sprite sheet](https://appliedmanifold.com/guides/godot-import-sprite-sheet/)[Dust along the ground →](https://appliedmanifold.com/guides/godot-dust-along-ground/)

05 // FAQ

## Explosion timing questions

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

**README.GODOT\_EXPLOSION\_SOUND\_SHAKE**

### How do I synchronize an explosion animation with sound and screen shake in Godot?

Start all three from one function on the same frame, driving shake and effect together while delaying distant sound by distance over 343.

### How do I combine a fireball, smoke, flash and shockwave into one explosion scene?

Place each element as a child of one explosion scene, offset their start times slightly and trigger them from one root script.

### How do I play a 3D sound effect in Godot?

Add an AudioStreamPlayer3D, assign your audio clip to Stream and call play() so volume attenuates with distance from the listener.

### How do I build a complete 3D explosion in Godot?

Layer a One Shot fireball sheet, a short OmniLight3D flash, debris particles and a smoke column, then trigger sound and shake together.

## 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/)
