terminalCode Example

Spatial audio components — SoundPoint, SoundBox, SoundscapeTrigger, DspVolume, and AudioListener

calendar_today May 5, 2026 schedule ~1 min read person patrickjr verified 50

Spatial Audio Components

s&box provides several components for placing audio in the world. All are alternatives to Sound.Play for persistent, positioned audio sources.

SoundPointComponent — Single Positioned Sound

CSHARP
var go = Scene.CreateObject();
go.WorldPosition = machinePosition;

var snd = go.Components.Create<SoundPointComponent>();
snd.SoundEvent  = "sounds/machinery/hum.sound";
snd.Volume      = 0.8f;
snd.Pitch       = 1f;
snd.PlayOnStart = true;
snd.Repeat      = true;

SoundBoxComponent — Area Sound Source

Sound appears to come from the nearest point on a box volume — good for large machinery or rooms.

CSHARP
var box = go.Components.Create<SoundBoxComponent>();
box.SoundEvent = "sounds/ambient/wind.sound";
box.BoxSize    = new Vector3( 400, 400, 200 );
box.Volume     = 1f;
box.PlayOnStart = true;
box.Repeat      = true;

SoundscapeTrigger — Ambient Zone

Blends ambient soundscapes when the listener enters a volume.

CSHARP
// Sphere trigger
var trigger = go.Components.Create<SoundscapeTrigger>();
trigger.SoundscapePath    = "soundscapes/outdoor_forest.sndscape";
trigger.Type              = SoundscapeTrigger.TriggerType.Sphere;
trigger.Radius            = 800f;
trigger.Volume            = 1f;
trigger.StayActiveOnExit  = true; // fade out rather than cut

DspVolume — Audio Effects Zone

Applies DSP effects (reverb, lowpass) to sounds inside the volume.

CSHARP
var dsp = go.Components.Create<DspVolume>();
dsp.VolumeType  = DspVolume.Type.Box;
dsp.BoxSize     = new Vector3( 500, 500, 300 );
dsp.DspPreset   = "dsp/reverb_cave.dsp";
dsp.TargetMixer = "Game";
dsp.Priority    = 1;

AudioListener — Custom Listener Position

By default the listener follows the main camera. Override it for security cameras, cutscenes, etc.

CSHARP
var listener = cameraGo.Components.Create<AudioListener>();
listener.UseCameraDirection = true;

Playing Sounds from Code

For one-shot sounds not tied to a component:

CSHARP
// At a world position
Sound.Play( "sounds/impact/metal.sound", hitPoint );

// On a GameObject (follows it)
Sound.Play( "sounds/footstep.sound", gameObject );
Was this helpful?