Skip to content

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

SceneObject

Usage

To use this class, add the following require at the top of your script:

local SgAudioListener = require 'engine/sceneobjects/sgaudiolistener'

Reference

create

static create(self, options, parent)

Create a new audio listener object in the scenegraph.

Parameters

  • self
  • options (table): A table of options to fill the parameters
  • parent (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