Forum rules - please read before posting.

Previous scene background music continues playing after Loading game

edited February 2016 in Technical Q&A
Hi, I ran into a situation in our game where after loading the game, the music that was in the previous scene continues playing over the music over the new scene. Here is our set up:

1. Added Sound to Scene With a Sound script - Type: Music, Play across scenes: Checked!
2. On start/load Action List, fade in the music sound on loop.
3. On walk out of the scene triggers, the action list has an action to fade out the music (if we don't want it anymore)
4. This is the same for most scenes in our game

AC: 1.46

Repro steps:
Save the game in a scene that has background music
Walk into another room with different background music
Load the game

Is there a better way to do this or to prevent the music from continuing to play while loading the game?

Thanks!

Comments

  • At the moment, you'll have to add the RememberSound and RememberTransform components and check "Save scene presence?" to both Sound objects.

    However, a new music system will be introduced in v1.51 that will make the process much more reliable and easier.
  • edited February 2016
    @ChrisIceBox I realized that we have a more complicated setup (long story short: I'm stepping a little later to help with this game and did not do the original music setup in the scenes :-) ).

    Basically, we want the ability to crossfade between one room music and the next, so the following was done in every scene:

    1. In the music sound game object, "Play across scenes" is checked.
    2. On the start cut-scene for the scene, we fade in the music.
    3. On leaving the scene from any trigger, we fade out the music.
    4. As it goes into the next scene, the music is continuing to play, but it also continues to fade out as the music in the new scene slowly fades in.

    I've found a few issues with this method that surrounds saving and loading the game as well as walking out and into the scene very quickly. Is there an option in the engine that allows for crossfading the music automatically or do we have to indeed do something similar to what we did?

    Btw, using Unity 4.6. I noticed in the AC source that the 5.0 implementation for sound is different.
  • AC in Unity 5 allows for the use of Audio Mixers, that make it possible to add effects and such.

    My recommendation would be to transfer to the new music system when it is released.  The playback of music will be automatically incorporated into the save system.  Not sure if crossfading will be a part of the initial phase, but I'll see if it can be.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.