How can I trigger 3D positional sound update?


I would like to trigger 3D positional sound update function when my object’s position changed. Is that possible? I can see when I do it on editor, it trigger this function but I couldn’t find a way to do it with scripting.

Best regards

Hi @commention,

Just to be sure I understand you fully, what method are you referring to?

On the AudioListenerComponent?

Audio listener part works perfectly. 3D positional audio doesn’t work for looped sounds. It works if i pause and play them again. Looped sound works but I can hear it that it uses first position. So I need to set new position on each update for looped sound.

Hmm, this sounds like a bug, looking at the source code I can see that positions for positional sound components are getting updated per frame.

Try submitting this on the engine repo to get more feedback and a resolution.

Thank you for your answer. I fixed problem on my side, also created a bug report.

For future searches about this subject I would like to share my code.

So you can actually update sound component’s position sound on each frame. But it should be on slots level, not sound component level.

this.entity.sound.slots[‘Slot 1’].updatePosition(this.entity.getPosition());

So basically you can updatePosition for each slot and hear them in 3D world as a 3D sound.

Also bug is basically about SoundComponentData file. It has no positional or slots variable, it only has enabled variable on it for some reason. Setting those variables manually also fixes issue.

If an example project needed for producing bug or testing 3D positional audio, this project can be used

Also here is the issue ticket on github about bug :

Thank you for help @Leonidas


Awesome, many thanks for sharing this insight @commention!