SgAudioListener
Represents the audio listener in the scene, typically attached to the camera or player. It determines how positional audio is perceived based on its location and orientation. Only one SgAudioListener should be active at a time to ensure correct spatial audio playback.
Inherits from
Usage
To use this class, add the following require at the top of your script:
Reference
create
Create a new audio listener object in the scenegraph.
Parameters
selfoptions(table): A table of options to fill the parametersparent(SceneObject): The parent scene object to add this to
Returns
Promise: promise which will resolve to the created object
Example
-- Options can be omitted. This example shows the defaults,
-- only specify the ones you want different.
SgAudioListener.create({
active = true,
name = "",
transform = Transform.new(),
layers = {0},
tags = {}
})
Properties
You can access these properties directly on the object or through :get("propertyName") or :set("propertyName", value) methods.
| Property | Type | Default | Description |
|---|---|---|---|
| active | Boolean | true | |
| transform | Transform | Transform.new() | |
| tags | Tags | [] | |
| gain | Float | 1 | |
| timeDelta | Float | 1 |