Use this guide when you want to play UI sounds, music, ambient loops, or spatialized world audio.
Use the audio system when you need:
Audio.PlaySound2D("Sounds/click.wav");
Use this for UI sounds, menu feedback, or simple non-spatial one-shots.
Audio.PlaySoundAtLocation("Sounds/explosion.wav", worldPosition);
Use this when the sound should come from a world position instead of the listener.
Attach AudioSourceComponent to an entity when the sound should belong to that entity.
Important properties:
| Property | Use it for |
|---|---|
SoundPath |
choose the source asset |
PlayOnStart |
start automatically with the scene |
Spatialized |
switch between 2D and 3D playback |
Looping |
keep the sound running |
Bus |
route to the correct mixer bus |
Volume / Pitch |
local playback adjustment |
AttenuationSettings |
3D falloff behavior |
Add AudioListenerComponent to the entity that should act as the listener.
If no explicit listener exists, the main camera is used as a fallback listener.
Use buses to control categories of audio:
| Bus | Typical Use |
|---|---|
Master |
overall output |
Music |
background music |
Sfx |
gameplay sound effects |
Ui |
menu and interface sounds |
Voice |
dialogue |
Ambient |
environmental audio |
Runtime volume control example:
Audio.SetBusVolume(AudioBusId.Music, 0.5f);
Audio.SetBusMuted(AudioBusId.Sfx, true);
Use AudioPlayParams when the default one-shot behavior is not enough.
Most useful options:
BusVolumePitchLoopingAttenuationOverrideExample:
Audio.PlaySound2D("Sounds/music.wav", new AudioPlayParams
{
Bus = AudioBusId.Music,
Volume = 0.8f,
Looping = true
});
AudioListenerComponent or a main camera fallback.project_settings.json.