Setting a mesh as the audio listener

Hi all!

I need to set my character mesh as the listener of sounds instead of the camera, since the player is away from the camera quiet a bit (65 units up, 65 units back).

I tried: Engine.audioEngine.audioContext.listener.setPosition(this.character.position)

That didn’t do anything it seemed, but then I moved it to the observable that moves the character and with moved it along with the character on every frame, that worked but the sound became very distorted.

Is there any other way to make a mesh the listener of spatial sounds?

Thanks in advance! :slight_smile:

Interesting question. So far this is not directly supported without hacking into the _afterRender function of the sound engine. The main problem is that the listener position is set where you are supposed to be (as the camera is supposed to be you :))

But we could definitely think about adding such a thing for 4.1

1 Like

Hi @Deltakosh,

Is there still a plan to implement this? Right now there is no possibility to implement a 3rd person camera without this.

I found this thread - Positional audio with camera attached to parent mesh - Questions & Answers - HTML5 Game Devs Forum in which Davrous talks about implementing the exact thing about 2 years ago.


We do not have an open issue for it in the repo (but feel free to open it) and we have no one who volunteered to do it (but we are open for help as well ;))

1 Like

With a little bit of guidance I should be able to implement this, as I have lurked around the audio engine for a bit researching this.

I’ll hopefully get time to do this sometime this week.

Thanks again :slight_smile:

1 Like

As it happens, I’ve encountered this problem before, and you can remove the following code from the babylonjs js file to fix it for the time being.:smiley:


All in!