Audio glitches more every time you respawn

The respawn works by just changing the scene to the current scene. After a few times of dying the audio will slowly get more and more glitchy each time, the console says there are no audio related bugs, can anyone help?

https://launch.playcanvas.com/1918628?debug=true

https://playcanvas.com/editor/scene/1918628

Hi @Brent_Reddick!

Presumably something is not removed properly when changing the scene, causing it to be doubled each time. As a result, you will probably notice the glitches in the sound.

I don’t really have an idea how to easily determine the cause, so hopefully someone else has a suggestion.

1 Like

Maybe, but the sound will eventually just mute, I will explore it, thanks!

Alright, found the source of the problem, its a bunch of positional sounds on loop, how do I code them to turn off right before the scene change, or something like that…

To be honest I expect this is all done by changeScene, because the entities with the components are destroyed.

You can try is to add the code below just before changeScene. (Not tested, so please let me know if it works).

this.app.root.findComponents('sound').forEach(sound => { 
    sound.stop();
});

1 Like

This fixed it!