Main Menu Music..?


I am trying to implement music with my main menu screen. I had found a way to play the music on event begin play but cannot find a way to stop the music once the game/level has started…

Here are my blueprints where I believe the music should go (MainMenu blueprint and Level blueprint). Please could someone help?

Store a variable with the spawned audio component when you play the music in the level blueprint, then when you’re closing the menu, reuse the variable to stop it.

Thanks for the answer! Bit new to Unreal 4, how do I make a variable I can use across blueprints? For instance I need to initiate this to play in the Level blueprint but need to stop it in the MainMenu widget blueprint… I get confused with using variables between blueprints… Thanks…

Personally, I’d make a menu menu game mode, with a main menu hud, which controls the music and spawns the main menu widget. That way, your game mode has a reference to the hud, and the hud has a reference to the widget, and the hud also controls the music.

So the menu game mode would almost be like another level? Is that what you are saying? Sorry get a bit confused with all the new language

Are you just having problems knowing how to stop a sound that’s playing? To do that you need to have an audio component to call stop on later. You can either save the one that’s created when you use Play Sound Attached:

Or create one manually and start it playing:

Then when you want the music to stop just call stop on the Audio Component variable you’ve stored.


1 Like

Thanks for the detailed explanation. Couple of points I’m running into… I have the game paused at Event Begin Play in my Level blueprint, how would I set the sound to UI? Also, out of curiosity, how can I have Event Begin Play fire multiple events? Currently it only allows one event to be executed… Thanks!

Could the music not be controlled entirely by the main menu widget? Not exactly my area of experience so I could be wrong. Another option that I’ve seen before is to literally have a level for your main menu, swapping between levels will stop any sounds that belong to the previous level.

There is a Set UISound node, which I assume will accomplish this, I’ve only done it by setting the Is UISound flag on a sounds accompanying Sound Class.

Not sure if I’m misunderstanding you on the Event Begin Play, as you can string any amount of nodes you like after the one directly attached to the event. Or you can use a Sequence node to make it easier to see groups of events that you want to execute one after another.

Just came across the sequence node so that cleared that up thanks :).

Yes the Set UISound works a treat, thanks again!

Sorry one last question, how can I use the ‘Audio Component’ variable in my Level blueprint in other blueprints? I can now play the music, but can’t find a way to again access and stop that variable in my MainMenu blueprint?

Getting out of my range of experience here but I wondered whether the audio component and sound playback could be part of your MainMenu blueprint? You can’t just access level variables from general blueprints as you can use the same blueprint in multiple levels and there’s no guarantee that different levels will have the same variables. As MulleDK19 suggested you can have a game mode to store the audio component and you then use the Get GameMode node to get the current mode and cast it to the main menu mode that you’re interested in.

Ah, I had thought maybe you couldn’t access Level variables in other blueprints, ■■■■ :(.

I have now got the menu sound working fine, thanks for all your help!