Add 3D Spatial Audio in Banter

BanterAudioSource plays audio from a GameObject in a Banter space. The component controls volume, pitch, mute state, looping, automatic playback, audio-effect bypass settings, and the blend between 2D and 3D sound.

Spatial Sound Setup

Place the audio GameObject at the sound source, configure BanterAudioSource, then trigger normal or one-shot playback from the interaction that needs it.

  1. Create a GameObject at the position where the sound should originate.
  2. Add BanterAudioSource with the required playback and spatial settings.
  3. Use Play() or a one-shot method from a scene or object event.

Create a 3D Audio Source

const speaker = new BS.GameObject({
  name: "Speaker",
  localPosition: new BS.Vector3(0, 1.5, 3)
});

const audio = speaker.AddComponent(new BS.BanterAudioSource({
  volume: 1,
  pitch: 1,
  mute: false,
  loop: false,
  playOnAwake: false,
  spatialBlend: 1
}));

The GameObject's Transform sets the location of a spatial source.

Audio Settings

Setting Purpose
volume Playback level from 0 to 1.
pitch Playback-speed and pitch multiplier.
mute Silence the source without removing it.
loop Repeat the audio.
playOnAwake Begin playback when the component becomes active.
spatialBlend Blend from 2D at 0 to 3D at 1.
bypassEffects Bypass audio effects.
bypassListenerEffects Bypass effects applied at the listener.
bypassReverbZones Ignore reverb-zone processing.

Use spatialBlend: 1 for fully positional 3D sound. Use 0 for non-spatial 2D sound.

Start Normal Playback

audio.Play();

Use playOnAwake: true when the sound should begin automatically. Use Play() when an event, button, trigger, or game state should control the start.

Play One-Shot Sounds

The API can play a clip by index or directly from a URL:

audio.PlayOneShot(0);
audio.PlayOneShotFromUrl(
  "https://example.com/sound.mp3"
);

One-shot playback is useful for individual effects that should not replace a looping or persistent source configuration.

Connect Audio to an Object Event

buttonObject.On("click", () => {
  audio.PlayOneShotFromUrl(
    "https://example.com/click.mp3"
  );
});

Register the event after the relevant GameObject and audio component exist.

Looping Ambient Audio

For ambient sound, set loop: true and decide whether playback should start automatically:

const ambience = area.AddComponent(
  new BS.BanterAudioSource({
    volume: 0.4,
    pitch: 1,
    loop: true,
    playOnAwake: true,
    spatialBlend: 1
  })
);

Place the source where its spatial origin makes sense in the scene.

Common Questions

Why does my Banter sound not feel positional?

Check the audio GameObject's position and the spatialBlend value. A value of 1 is fully 3D, while 0 is 2D.

Why does my sound begin as soon as the space loads?

Set playOnAwake to false and call Play() or a one-shot method from the intended event.

Official References

Related Navigation