Really Need Help with Music Logic

Hi everyone! There are a few questions I really need help with. I can't seem to figure them out at all and I need them answered really badly. :/

So in my game I have a scene where when the player dies you can reset the scene. I have music playing, but every time the scene resets, so does the music, and it gets annoying having the song reset every time it dies. Is there anyway I can fix this using attributes or anything like that?

Second, I have a splash screen that plays a certain song which then carries over into the level select, but then when I play a level, and the level is done, and I go back to the level select, the music from the level is playing on the level select screen. I was able to stop this by creating a "levelOneOn" attribute and telling it to go false when on the level select screen, and when it's false to play the other music, but this then makes it so when I initially go to the level select from the splash screen, the music resets since I have an actor telling it to play music if my "levelOneOn" attribute is false. What do I do in this situation?

Overall, I'm just very confused about music and how you can play it across various scenes while excluding it from others. Any help and advice would be very nice and help a ton!! Thanks!

Comments

  • ArmellineArmelline Member, PRO Posts: 5,369

    Music will keep playing until you either tell it to stop, or tell other music to play. If you've got the behaviour to tell the music to play on a scene and you reset the scene, what you're doing is essentially telling it to play new music. It's the same music, but a new request to play it.

    If you don't want the music to reset with the scene, either avoid resetting the scene and do the resetting manually, or trigger the music prior to the player reaching the scene.

    The reason your level music is playing on the level select screen is the same - you're telling Music A to play on the Menu scene, and not giving any further instructions when the player moves to the Level Select scene, so Music A is still playing. When you start a level, Music B begins and when you go to the Level Select scene from the gameplay scene, you're not telling any other music to play so Music B continues.

    To solve your levelOneOn problem, perhaps set it to go true when returning to the Level Select from the gameplay scene, and have it only start the music on that scene when the attribute is true. Just remember to set it to false once you've triggered the music. It will be false when initially arriving at Level Select from Menu, and will be true when arriving from Gameplay. But since you reset it to false almost immediately, it will be false when you return to Menu (where you'll need a similar trigger).

    It's confusing I know but just think about it like this: Music will play until you tell it to stop or tell something new to play. Telling the same thing to play for a second time is the same as telling something new to play.

  • kelseabarkerkelseabarker Member, PRO Posts: 15

    @Armelline Thank you very much for your fast response! :) I see what you're saying, and I feel like I understand it better. I will try your suggestions right away. Thanks again for helping me and for taking your time to help others too! :smiley:

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    This is why I normally import as sound files and not music, much more control.

  • NalycanNalycan Member, PRO Posts: 97

    In our new game we start an almost empty scene just with the music loop rule and change scene to game scene. When "game over" we reset the game scene, music continues to loop perfect in the background.

Sign In or Register to comment.