How to add sound effects in Godot 4
Updated Nov 19, 2026
TL;DR: Import a .wav or .ogg into your project, add an AudioStreamPlayer (or AudioStreamPlayer2D for positional audio), set its Stream, and call $Player.play(). Put SFX on their own audio bus. Use AudioStreamRandomizer so repeated hits are not identical. Watch looping, empty streams, and the default max_polyphony of 1. Need files first? See free sound effects for Godot.
1. Import the files
Godot 4 accepts WAV, Ogg Vorbis, and MP3. Official import documentation recommends WAV for short, repetitive sound effects (cheap to play back, larger on disk) and Ogg Vorbis for music, speech, and long effects (much smaller, more CPU). Copy the files into a folder such as res://sfx/; Godot imports them automatically.
Select a file and check the Import dock. For one-shot SFX, keep looping disabled. On WAV files, Edit > Trim can remove leading silence so the hit starts immediately. Reimport after changing those options.
2. Add AudioStreamPlayer or AudioStreamPlayer2D
An audio stream is the resource; an AudioStreamPlayer is the node that plays it.
- AudioStreamPlayer is non-positional. Use it for UI clicks, menus, stingers, and music. The docs describe it as ideal for those cases.
- AudioStreamPlayer2D pans in a 2D environment: close to the left of the screen the sound goes left, close to the right it goes right.
- AudioStreamPlayer3D does the same in 3D. Skip it until you have a 3D listener setup.
Add the node to the scene. In the Inspector, assign Stream to your imported sample. Leave Autoplay off for sound effects. Set Bus to SFX once that bus exists (next section). Rename the node to something you can reference, such as Player or Hit.
3. Play it in GDScript
The method is play(from_position: float = 0.0). With a node named Player:
extends CharacterBody2D
@onready var sfx: AudioStreamPlayer = $Player
func jump() -> void:
velocity.y = jump_speed
sfx.play()
$Player.play() is enough for a single one-shot. If you need to start later in the file, pass a time in seconds: $Player.play(0.15). Call stop() to halt playback. The finished signal fires when a sound ends on its own; it does not fire if you call stop().
Setting the stream property stops any sound already playing on that node. If you swap clips on one player, assign the new stream and then call play().
4. Audio buses
Open the Audio panel at the bottom of the editor (see the official audio buses tutorial). The default layout has a Master bus. Add buses for Music, SFX, and optionally UI, and leave them sending to Master. Then set each player's bus property to the matching name, either in the Inspector or in code:
$Player.bus = &"SFX"
You can now mute or change the volume of all sound effects without touching music, and you can add a limiter or a light reverb on the SFX bus instead of baking it into every file. If a bus name is missing at runtime, Godot falls back to "Master".
5. Pitch and volume randomization with AudioStreamRandomizer
The same sword file played at the same pitch every swing sounds mechanical. Godot's AudioStreamRandomizer is an AudioStream that wraps a pool of clips. Each time it is played it picks a stream from the pool (by default avoiding an immediate repeat) and can apply random pitch and volume.
random_pitchis a frequency multiplier range:1.0means no variation;2.0randomizes between half and double. A value around1.08is a mild variation.random_volume_offset_dboffsets volume by up to that many decibels in either direction.3.0means between −3 dB and +3 dB.
Assign the randomizer as the player's Stream. In the Inspector, raise Streams Count, slot in sword_01, sword_02, sword_03, and set the random ranges. Or build it in code:
extends Node
@onready var player: AudioStreamPlayer = $Player
func _ready() -> void:
var randomizer := AudioStreamRandomizer.new()
randomizer.random_pitch = 1.08
randomizer.random_volume_offset_db = 1.5
randomizer.add_stream(-1, preload("res://sfx/sword_01.wav"))
randomizer.add_stream(-1, preload("res://sfx/sword_02.wav"))
randomizer.add_stream(-1, preload("res://sfx/sword_03.wav"))
player.stream = randomizer
func swing() -> void:
player.play()
add_stream() inserts at the end of the pool when the index is less than zero, which is why the examples use -1. Paths under res://sfx/ are examples — point them at your actual files.
6. A one-shot SFX pattern
Two reliable patterns:
Reuse one player, allow overlap. Leave a dedicated AudioStreamPlayer in the scene, assign its stream (or a randomizer), and set Max Polyphony above 1. The property's default is 1, and the class reference says that calling play() after the cap is reached cuts off the oldest sound. For machine-gun or rapid footstep overlap, try 4 or 8.
# Inspector: Stream set, Bus = SFX, Max Polyphony = 8
func hit() -> void:
$Hit.play()
Spawn a short-lived player. Useful when many different clips fire from one manager and you do not want them to interrupt each other:
func play_one_shot(stream: AudioStream, bus: StringName = &"SFX") -> void:
var p := AudioStreamPlayer.new()
p.stream = stream
p.bus = bus
add_child(p)
p.finished.connect(p.queue_free)
p.play()
The finished signal is documented to fire when playback ends without being stopped, which is when it is safe to queue_free() the temporary node.
7. Common mistakes
- Loop left on for a one-shot. A click or explosion that loops in the Import dock (or WAV loop metadata) will not end, and
finishedwill not fire. - Empty Stream. If
streamis unset, the player does nothing. Assign the resource beforeplay(). - Calling
play()every frame in_process. You will restart the sound continuously. Call it once from the event (jump, hit, button press). max_polyphonyleft at 1 when two hits should overlap. The new play cuts the old one off.- Using AudioStreamPlayer2D and wondering why a far-away object is quiet or panned. That node is positional on purpose. Use a plain
AudioStreamPlayerfor UI and full-screen stingers. - Music and SFX on Master only, so you cannot mute effects independently. Give SFX their own bus.
- Long music imported as uncompressed WAV, which bloats the export. Prefer Ogg Vorbis for long files.
- Assuming every free download is commercial-safe. See free sound effects for Godot for CC0 vs CC-BY vs non-commercial licenses.
Sources: Godot Engine stable docs for importing audio samples, audio streams, audio buses, AudioStreamPlayer, and AudioStreamRandomizer.
Free + paid SFX for your game
These are our own Assetsmith packs on itch (ordinary product links, not affiliate). The Analog Horror VHS SFX free sampler is nine tape/CRT sounds (WAV + OGG), listed as name-your-own-price / free. The page allows use in your own commercial or non-commercial projects and forbids resale or redistribution of the raw files; it is not CC0. Fantasy RPG Combat SFX is 406 combat sounds at $3.99 USD or more. The Fantasy RPG SFX Bundle is 763 sounds (combat, magic, loot/UI) at $5.99 USD or more. Both paid packs are WAV + OGG with a royalty-free game license, no credit required, and no resale of the raw files. Prices checked on the live itch pages on 19 Nov 2026 (Europe/Berlin); itch listed prices are minimums.
Fantasy RPG Combat SFX — $3.99+ Fantasy RPG SFX Bundle — $5.99+ Free VHS SFX sampler
Free 10-sound Combat SFX sampler (WAV+OGG, Godot-ready)
Free 11-sound Retro FPS SFX sampler (WAV+OGG, Godot-ready)
Also from Assetsmith: Cute Farming SFX (230 soft farm sounds, $2.49 USD or more) and Retro FPS SFX (235 boomer-shooter sounds, $2.99 USD or more, with a free 5-sound demo on the same page). Catalog: assetsmith.pages.dev.
FAQ
How do I play a sound in Godot 4 with GDScript?
Add an AudioStreamPlayer, assign a stream, then call play(). If the node is named Player, $Player.play() starts the sound from the beginning.
What is the difference between AudioStreamPlayer and AudioStreamPlayer2D?
AudioStreamPlayer is non-positional (UI, menus, music). AudioStreamPlayer2D pans left and right based on the node's 2D position relative to the listener.
How do I randomize pitch and volume so sword swings are not identical?
Use an AudioStreamRandomizer as the player's stream, add variations to its pool, and set random_pitch and random_volume_offset_db.
Why does my sound cut off when I play another one?
max_polyphony defaults to 1. Raise it, or spawn a temporary player and free it on finished.