Skip to content

Audio Positional

Updated

3D sound that gets quieter with distance.

Type
comp-audio-positional
Script class
PositionalAudioComponent
Per entity
One
Version
1.1.0

Read about it in Spatial audio: what it does, how to use it from a script, and examples.

The props the runtime declares for this component, with their defaults and accepted ranges.

Prop Default Range
maxDistance 0.001 ≤ x ≤ 10000
refDistance 0.01 ≤ x ≤ 10000
rolloffFactor 0 ≤ x ≤ 10
volume 0 ≤ x ≤ 1

Sent to the entity’s Signal Emitter as { entityId, eventType, data }. Compare eventType with the EventType constants.

  • AudioPositional::ready
  • AudioPositional::error
  • AudioPositional::play
  • AudioPositional::pause
  • AudioPositional::stop
  • AudioPositional::end

Run it in the browser, read its scripts, and download it as an XR Creator project.

#pragma lifecycle(startup)
function startup() {
const component = self.parent.getComponent(PositionalAudioComponent);
if (component) log(component.props);
}