Main Menu music fade in and out?

Hi, so I’ve created my main menu but I am struggling to get the music to fade in and out.
For example, when you first click play I want the main menu to be displayed and then have the music fade in, and once the player has clicked played I want it to fade out.

Can anyone help?

Try adding a Fade In node from your audio component. Read more here: Fade In | Unreal Engine Documentation

You’ll want to keep a reference to the audio component that you’re playing so you can trigger a Fade Out when necessary Fade Out | Unreal Engine Documentation


I whipped up a quick example to check out. The biggest headache from working with a Level Blueprint > HUD is going back from the HUD > Level Blueprint. It would all be much easier to manage if you just created a new GameMode for menu activities. This way, you could create a PlayerController that can help with this.

So, say. I have BP_GameModeMenu, BP_MainMenuPlayer, MainMenu (level) and MainMenuHUD. The MainMenu (level) uses BM_GameModeMenu, which points to BP_MainMenuPlayer.

MainMenuHUD

BP_MainMenuPlayer

Perhaps a little overkill, but should get you moving!

1 Like

I have managed to get the audio to fade in but fading out still seems to cut the sound off straight away.

That’s likely because it’s being destroyed immediately. You may want to add a short delay as you transition away from the menu.

Ok thanks, where would I add this?

You’d want to create a new event before triggering OnMenuExit. The new event would replace your OnMenuExit node in order to allow the audio to fade fade. Once the fade out completes, then you would be safe to move on.

As a test, just so you can see that the fade out works. Create a new event and trigger that instead of leaving the menu (so keep the menu loaded, don’t change to a new level).

Also, just to clean things up a bit. Instead of dragging from the Audio Component node above, drag in a new node & select ‘GET’. Do this first & test again.

I’m a little confused, I am unable to use my audio component where I tell my menu to change level when the player clicks start. Therefore I cannot assign the target.

Had time to whip up an example. I didn’t stay on the same path, but it’ll give you another route to consider (cleaner IMO). See the updated answer.

Now, you’re probably going to notice unwanted behavior. You have to wait… before you can transition. You could gain a little more time by fading out the UI and shortening up the Fade Out. At the end of the day it’ll need to be quick/responsive. One thing you could look into is Level Streaming, where the audio can be handled on the persistent level.

I managed to figure out a way to do it in the main menu widget. I was able to get the music to fade in on starting the game and then get it to fade out when the prologue screen is just about to close.

Excellent! Almost forgot! I’d certainly appreciate an up vote if you found anything helpful. Best of luck on your journey!