Aego Русский

Audio Listener 2D

Hears spatial sound from its node. Without one the camera of the main output listens.

component audio.AudioListener2D
On this page

Try it

Choose the effective listener

The blue mark is an active listener at x=2; the gray mark is the camera at x=0. The orange marker reads the effective position from the real audio service. No sound is played.

Disable Active. After the scene restarts, the service uses the camera fallback and the orange marker moves to x=0. Reset restores the active listener.

Starts the scene; open the example parameters to experiment.
Open in AegoDownload example project
Scene4 nodes
Listener
Transform
position[2, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")tintColor#38bdf8ffsizeVec2[0.4, 3]
Camera position
Transform
position[0, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")tintColor#9ca3afffsizeVec2[0.4, 3]
Effective listener
Transform
position[0, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000d00")tintColor#f59e0bffsizeVec2[1.5, 1.5]orderint1
Camera
Transform
position[0, 0]rotation0scale[1, 1]
Camera 2D
zoomfloat40clearColorColor#111827ffscaleenumfitVirtualvirtualVec2[960, 540]activebooltrue
Scriptmain.aes
package demo

import "aego/audio"

// The marker shows the position returned by the real audio service, including
// camera fallback. It does not change the listener or start a sound.
script ListenerIndicator {
    func Update(dt float) {
        node.SetPosition(audio.ListenerPosition())
    }
}

Fields

NameTypeDefaultDescription
Activebooltrue

The first active listener in the hierarchy is used.