Sound

Sound

Adding sound in your environment can significantly enhance the user experience. The easiest way of adding a sound is by using the Audio component.

Audio source

You can use either a Hiber preset sound by specifying an id or an external audio file by specifying a url.

<Audio src={{ id: "a_am_city_01" }} />
<Audio src={{ url: "https://my-external-audio.mp3" }} />

To find a complete list of available preset sound ids try filtering by "Audio" in the Asset Browser

Soundscaping

Control of how the sound changes ('attenuates') as you move around in the world is controlled by the

  • volume defines the volume as a range from 0 (silence) to 2 (max)
  • attenuationModel - NO_ATTENUATION, INVERSE_DISTANCE, LINEAR_DISTANCE or EXPONENTIAL_DISTANCE
  • minAttenuationDist and maxAttenuationDist
  • rollOffFactor

Starting a sound

A sound can either be started on world start, when the player comes within startPlayingDist range, or triggered on a playOnSignal.

Looping

A sound can either be played once, or in a continous loop. This is controlled with the looping property.

<Audio src={{ id: "a_am_city_01" }} volume={3} />
<Audio src={{ url: "https://my-external-audio.mp3" }} volume={3} />