Play Music Across Scenes?

JoshKahaneJoshKahane Member Posts: 470
Hi

I have given it a search and all sorts but can't get this one figured out. I have imported my music as music not a sound and set it to play on an actor which is present in every scene. I want the music to continue playing from where where it stop either when the scene resets or changes. I don't want it to start from the beginning of the track every time which is what is currently happening? How can I achieve this? Thanks.

Kind regards,
Josh Kahane.

Comments

  • quantumsheepquantumsheep Member Posts: 8,188
    Take the sound out of the actors on the other screens - just have it on the initial screen.

    Even better:

    On one of my projects, I have an 'intro' screen. When it moves to the title screen (press a button, say, or on a timer) it starts the music playing with the 'play music' behaviour on a loop.

    Now it doesn't need to be anywhere else. Just make sure that if you reset the game, it goes back to the intro screen first to kick off the music.

    Hope that helps!

    QS :)

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • JoshKahaneJoshKahane Member Posts: 470
    Hmmm. Either I have terribly misunderstood you or it just doesn't work, hehe. Thanks for the help quantumsheep, but I have placed it onto my main menu scene and only there, no one else in the game does it have any music or sound rules and it plays.

    Now, it starts playing and plays continually into my level select scenes, easy, normal and hard without an issue. Then if I actually start level 1 or any other level it stops. How odd. Any ideas?

    EDIT: Ahh ok a thought about it not working when starting any levels, I have the scene restart at the beginning of every level. Would it have an effect?

    EDIT 2: Ok I have tried removing the reset scene function which is at the start of every level (I swear I had such brilliant reasoning for putting that there ages ago, not sure why, I will soon see if it breaks something) :) Without ti reseting at the start of every level the music now continues through to the level.

    Ok my issue now is that when I die I have to reset the scene and that stops the music. What can I do?
  • quantumsheepquantumsheep Member Posts: 8,188
    "when I die I have to reset the scene and that stops the music. What can I do?" - that sounds like a plea from beyond the grave ;)

    To be fair, I'm not sure. I have different music per level in most of my games now so this hasn't come up much!

    Maybe work around a different way to reset the level? What I do, is have a timer start at the beginning of a level. Then when the timer hits certain points (30 seconds, 44 seconds etc) I spawn bad guys.

    Therefore, if I need to reset the level, I have some rules that say:
    If player is dead
    Destroy enemy actors (this rule would be in the enemies themselves)
    Reset time to 0.
    Reset anything else you want reset (e.g. score).
    Spawn player actor.

    This should work as you're not actually using 'reset'.

    Hope that helps,

    QS :)

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • firemaplegamesfiremaplegames Member Posts: 3,211
    you cannot use Reset Scene. Unfortunately, that will kill the background music. Hopefully they will fix it.

    The only way I know to do it is to use Change Scene and keep track of the current level that you are on, like this:

    When game.currentLevel = 1
    Change Scene to Level 1

    You will need 1 Rule for every Scene.
    It gets to be a lot of fun when you have 80 scenes like danger cats...
  • adent42adent42 Key Master, Head Chef, Executive Chef, Member, PRO Posts: 3,170
    One trick is to pause the music at scene exit, then resume it first thing on scene load.
Sign In or Register to comment.