Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: colpolstudios on November 25, 2013, 07:28:44 AM
-
I found a very good music track that loops and wish to use this for my main splash screen.
But I want the music to continue from its last point when I load into the next scene.
So you here the music seamlessly.
I am unsure how to set this up.
Could someone please help.
-
I would try this:
Add a GameObject to your first loaded scene and call it MusicManager.
Add an FSM with Audio Play and Don't Destroy On Load actions. This will keep the MusicManager around when loading new scenes.
You might also have to store the current play time in a global variable if the music resets to the beginning on load. Use Get/Set Property with the audio.time property to store/restore the play time.
I haven't actually tried it, but it seems like something like this should work.
There might also be some clues in Unity Answers:
https://www.google.com/search?q=unity+play+music+across+scenes
-
a few minor changes needed.
audio play action not needed.
no need to store the current play time in a global variable.
Add a GameObject to your first loaded scene and call it MusicManager.
only add Don't Destroy On Load action.
In the inspector select the audio source
check play on awake and loop.
That's all you need if you wish the sound to play through all loaded scenes.
For me the sound did not stop and restart but played seamlessly.
I did not want this track to play at the same volume through every scene.
Using a global Int level set to zero
new state added to the MusicManager
int compare global level compare to 1
equal or greater than
every frame checked.
custom event lower music
new state lower the music
action: set audio volume I simply lower the value to 0.2.
The trick was the global value of level currently zero
one is added at runtime when you load the scene.
The MusicManager is still checking and moves you to the lower music state.
Sound is lowered instantly, a slow fade would be nice.
The volume begins at 1 and I set it to 0.2 this is noticeable.
Any advice on the best way to slowly fade from 1 to 0.2 would be very helpful
-
You could use Float Interpolate or Ease Float to gradually change a float variable that you use to set the volume...
-
Ease float did not work however float interpolate DID WORK.