Hi Chris!
I believe I found a bug.
I have a Sound-Component with type set to Music.
Play across scenes is checked, GameObject is in root and has a ConstantID.
I play the Music via ActionList and Auto-end-other music is off.
Music is playing.
I switch to PlayerB (in another scene) and a scene change happens. Music keeps playing.
I switch back to PlayerA - scene change happens - and the GameObject with the Sound is destroyed.
Is it a bug or am I missing something?
Best, Alex.
AC Ver: 1.75.4
Unity: 2020.3.33f1
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Looks like a bug - thanks for the report.
I'll look into it, but I'd still recommend you rely on the dedicated Sound: Play music Action, which simplifies the workflow by removing the need for a dedicated Sound object in the scene. This Action allows for music to play across scenes without need for any additional setup.
Thanks for confirming it.
I need music played through Sound-Component, because I play multiple tracks in parallel and crossfading them depening where the player is in the scene. I didn't found a solution with the Sound:Play music action for that.
I'll look also into it and post here when I found a fix.
To fix, open up Sound.cs, and look for the OnInitialiseScene function (around line 576 in the latest release).
In that, look for the code block:
Replace with:
This fixed the destroying of the Sound Object.
But now the Sound->Change volume action lost its Sound Object when re-entering the scene.
I guess this action would need the ability to use Constant-ID references to the Sound-Object in the scene.
Move that Action to an ActionList asset file, and have it reference the sound object in the scene.
That'll cause it to create a reference via Constant ID, so it should work upon re-entering.