I'm adding sound object to the root of the hierachy. Also choose music and click on play across the scenes. Itplays on wake.
The problem is, though the sound plays on the scene and we can go to other scenes. When we come back to the room that has sound in its hierachy, the song starts again while the first song still plays. So it duplicates.
What might be wrong? How do we aproach this problem?
Thanks
Comments
Now what i have is, the song plays across all rooms from where it left off in previous scene. However if we come back to the room the song originated, the song starts from the begining rather than continuing just like while in other rooms.
Is this the desired result or am i missing something?
Thank you once again
-Fixed: Using the Engine: Play sound
Action to play music causing the music to restart if the clip was already
playing
I have music that is to exist between scenes, has
no parent object, is set to loop in the audiosource itself and on the
Play Sound action, and flows just fine until I enter a scene that calls a
Play Sound on it again and it restarts. I noticed ActionSound.cs checks
if audioClip is the same as whats
playing, but audioClip is the optional change of the clip itself.I assumed such a check would be in the Run() function but I am failing to see where this check would be.
Whats the reasoning behind only allowing one sound to play through scenes without restarting or am I the first to run into this?
In this case I try an action to fadeout the music and it does not work. I presume it runs the action on the copy that is not playing. The sound objects and the prefab have the same constant ID. I feel like I am very scoped in terms of sound flexibility here. How is everyone else getting by with having a lot of scenes?
1.
If I use a Play Sound action on a Music sound I expect it to play
without affecting other music sounds. Likewise if I play two music files
consecutively I would expect them both to play. A bool set for stopping
all other music or not would help support both cases.
2.
Following #1, if a music file is already playing and I tell it to play
again, there should be an option of whether or not to restart the sound or leave it to play at its current spot. It seems odd to have to place the
same exact clip that the sound uses into the optional new clip field to
prevent the sound from restarting. A play action could have a bool of
"Restart" to indicate to restart the sound if it is already playing.
3. I can't think of any reason why other sound files can't also exist between scenes.
4.
If a sound file is existing between scenes there should be a solution
in place to remove a duplicate sound object from the new scene. One way
to do this is on the Awake() function search for an identical sound
object (check constant id) and if found, then have the object delete
itself.
Thoughts?
I'm not sure of the bool suggestion in 1). I see the need for it, because AC assumes that only one music track will ever get played at one time - which I think is a safe bet. You're making use of multiple music tracks, but you've said that that's because you're having to rely on them for SFX as well.
If SFX tracks could survive scene changes in the same way that Music tracks do, would that eliminate the need? Music tracks would always play one-at-a-time, SFX tracks would always play independently.
However you didn't mention how you felt about #4. I think its quite an important part when having objects that don't destroy on scene loads.