Play the same sound with multiple volume config simultaneously

Hello,

I am trying to give each GameObject a specific sound volume according to their distance from the player.

Currently, I am using a shared sound object and I give volume as a parameter when calling “play” :
this.audioList['blast'].play({'volume':vol});

However, it does not work when there are lots of GameObjects.
I think that each sound object share the same volume with all its instances.

So what is the recommended way to manage a list of sounds which can be played by different GameObjects with their respective volume ?

Are you using Web Audio (see console banner)?

If you want to play a sound and do nothing else with it, you don’t need to manage anything, you can just call

this.sound.play('blast', { volume: vol });

each time.

If you’re creating sound objects instead, you need one sound object per sound asset per game object, probably. Each sound object is like one audio track — one playback position, one volume.

Yes, you’re exactly right.
I was creating sound objects with this.sound.add() before playing them.
Instead, it works perfectly when playing sounds directly, otherwise I should create sound objects in each game object.

Many thanks!