Skills

Audio System

Use when implementing audio, audio buses, AudioStreamPlayer, spatial audio, music...

Install

npx skills add jame581/GodotPrompter --skill audio-system -g -a claude-code -y
Category
Media
Updated
3d ago
License
MIT
Context cost
Mediumabout 3,000 tokens
Runs scripts
No, instructions only

What it does

Use when implementing audio, audio buses, AudioStreamPlayer, spatial audio, music management, SFX pooling, and dynamic mixing

Audio System in Godot 4.3+

All examples target Godot 4.3+ with no deprecated APIs. GDScript is shown first, then C#.

Related skills: event-bus for decoupled audio triggers, save-load for persisting audio settings, resource-pattern for audio data containers.


1. Core Concepts

Audio Node Types

NodeDimensionsUse For
AudioStreamPlayerNon-positionalMusic, UI sounds, global SFX
AudioStreamPlayer2D2D positionalFootsteps, gunfire, environmental sounds
AudioStreamPlayer3D3D positionalSame as 2D but in 3D space

Audio Bus Architecture

Godot routes all audio through buses (like a mixing console).

Master (always exists)
├── Music          → volume, effects for background music
├── SFX            → volume, effects for sound effects
│   ├── Footsteps  → sub-bus for fine-tuning
│   └── Weapons    → sub-bus for fine-tuning
└── UI             → volume for menu sounds

Setup: Bottom panel → Audio tab → Add buses, set names, route outputs.

Every AudioStreamPlayer has a bus property, set it to the target bus name (e.g., "SFX", "Music").


2. Basic Audio Playback

GDScript

extends Node2D

@onready var sfx_player: AudioStreamPlayer2D = $AudioStreamPlayer2D
@onready var music_player: AudioStreamPlayer = $MusicPlayer

func _ready() -> void:
    # Play background music (looping is set on the AudioStream resource)
    music_player.play()

func play_jump_sound() -> void:
    sfx_player.stream = preload("res://audio/sfx/jump.wav")
    sfx_player.play()

C#

using Godot;

public partial class AudioExample : Node2D
{
    private AudioStreamPlayer2D _sfxPlayer;
    private AudioStreamPlayer _musicPlayer;
Read the whole SKILL.md on GitHub

More in Media