Play Music via Main & Settings Menus

Just curious as I can’t seem to find anywhere on the net about this (unless I’m just asking the wrong question). Basically, I have my main and settings menus set up and their working fine. I also have music in them, however when I go to my settings menu, the music starts from the beginning and vice versa when I go back to the main menu. How do I get the music to play continuously between both menus instead of starting again? Any help would be much appreciated.

You need to start playing the music in the code that loads the menus.

I’m not sure how to implement it properly though. Are you speaking about Blueprints or C++, or does it work in a similar way with both? I’m using Blueprints as I prefer visual scripting to coding personally.

I have it set up with an Event BeginPlay, I know anything attached to this starts the moment a level is started, and I’m not sure how to implement it to play continuously over each menu rather than restarting each time.

Blueprints is fine.

I just re-read your post. I’m working on the assumption you have music A for the main menu and music B for the settings, right?

In that case, when you play the music in the main menu ( for instance ), and the player hits a button for the settings, you have to make a note of how far into the music you were and put it in the game instance ( or the player character, or… somewhere else ).

Next time the player loads the main menu, you player music A, but you start from where you left off, which you get from the game instance ( or… )

Does it make sense?

Yea, that makes sense. I’ll have a look and let you know if I get it working properly.

Thanks for the advice :slight_smile:

Tell me if you get stuck…

I’ve managed to sort it out, I was doing it all wrong. I had a separate level set up for each menu, and then had the music playing on Event Begin Play. Did not click at first that this would obviously start it from the beginning lol.

So, I made the menus within the same widget BP, and then set the music to the Event Begin Play and it works fine. I was being a spanner :).

I’ll bear that in mind for the future, it probably would be easier doing it with separate levels for the menus. I just found this way easier for now. This is the first game I’m building so it isn’t going to be huge, but I do eventually want to work on a larger game which will be more in depth. So, I’ll have a look into that later down the line when I have more experience with the engine.

Thanks again for the help.

No worries. You can do it with separate levels, but then you need to start the music in the persistent and stream the others…