Sound’s volume does not change when sound is playing at runtime with code.It remains the same. But when you pause/stop sound in code, then change music through code and pl?ay it again through code, it starts to work fine on new volume.Can anyone solve this problem?
How are you currently changing the volume? Can you show the code please?
I tried both
Both doesnt change the volume of playing sound.
But Stopping/Pausing and then changing the volume then playing sound changes volume.
Do you want to change the volume for that particular sound / slot or globally (ie all sound in the game/app)?
For starter, I just want to change the volume of a playing sound without stopping and playing it again and again if that’s possible in playcanvas.
Be it volume for that particular sound/slot or globally
PlayCanvas returns a reference to a pc.SoundInstance when you play a sound (see doc here: https://developer.playcanvas.com/en/api/pc.SoundComponent.html#play).
If you need to change the volume of an already playing sound, you have to have the reference to the sound instance and change the volume on that: https://developer.playcanvas.com/en/api/pc.SoundInstance.html#volume
If you want to change it globally, it’s a lot easier as you can do it via the global manager https://developer.playcanvas.com/en/api/pc.SoundManager.html#volume
this.app.systems.sound.manager.volume = 0.1
volume is a number, not a string (see API ref).