SgPositionalAudio¶
Plays 3D spatialized sound, with volume and panning based on listener distance and orientation. Used for immersive effects like footsteps, explosions, or ambient sounds. Can be attached to moving objects for realistic audio tracking in the scene.
Inherits from¶
Usage¶
To use this class, add the following require at the top of your script:
local SgPositionalAudio = require 'engine/sceneobjects/sgpositionalaudio'
Reference¶
- class SgPositionalAudio¶
- module:
- create(options, parent)¶
Create a new positional audio object in the scenegraph.
- Parameters:
options (
table
) – A table of options to fill the parametersparent (
SceneObject
) – The parent scene object to add this to
- Returns:
a promise which will resolve to the created object
- Return type:
Promise
- play(force)¶
playback the audio
- Parameters:
force (
boolean
) – Force the sound to replay even if it is already playing
- stop()¶
stop the audio
- isPlaying()¶
Checks if the audio is playing
- Returns:
true, if sound is playing, false otherwise
- Return type:
boolean
- getAudioCollectionEntry()¶
- setAudioCollectionEntry(name)¶
- Parameters:
name (
any
)