Artboard volume not updating immediately
Hello,
I’ve written my own game engine and am using the WebGL2 Advanced runtime.
I’ve got a function that runs while characters move. It iterates through all the rive instances in the world, gets the proximity to the player, and then updates the audio volume to give an impression of space.
This works well for the most part, but I recently added some longer audio files to things like waterfalls and streams. The loop in this video is 4 seconds long. What seems to be happening is the audio volume does not adjust until the previous loop stops and the new one starts. You can see in the example video below that the volume level jumps after about 4 seconds. I’m guessing things like footsteps which you can also hear in the sample are doing the same thing but aren’t noticeable because they are so short.
I’m guessing this is an issue with how the artboard volume update function works where it doesn’t update sounds that are already playing. Is there some way to fix this?
I’ve attached the waterfall rive file with the audio.
This is my update function that is called when the position of any character changes on all objects in the room:
// update volume of character based on proximity to player
this.updateVolume = () => {
if(this.artboard != undefined && this.artboard.hasAudio) {
var distance = 0;
var position = this.position;
if(this.audioX != 0 || this.audioY != 0) {
position = new Position(this.audioX, this.audioY);
}
if(this.currentScene == Game.CurrentPlayer.currentScene) {
distance = getDistance(position, Game.CurrentPlayer.position);
}
var volume = (Sound.GetSoundVolume() * 0.01) - (distance * 0.1);
this.artboard.volume = volume;
}
}minewaterfall.rev20250418-1607-26.7736893.mp4