Hide control buttons in menu

When I go to menu the button is still there how can I hide that controls ?

This is the blueprint of my RETURN TO GAME MENU

Hey there @BeastNectus! So it’s dependent on how those controls are set up. If they are set up as a standard UMG widget, you can open their widget BP, add an event to disable it.

If it’s UMG:
image

Just change the visibility on the blueprint whenever you’re on the main menu level.

If it’s a HUD class then you will have to get your HUD class and disable it at that time a little like this:

Hope this helps!

1 Like

My problem is like this

I understand! First we have to determine how your game applies that UI. From your video it looks like it’s like a UMG button widget set up when the player spawns. Could you take a look inside the player BP, the level BP, and the Gamemode BP to see which one is spawning and applying the UI? It’s likely the player. Once there we need to determine a number of things, if you want to destroy the UI or just hide it with the visibility settings I had before. If a new one is going to spawn every time a new level starts, we can safely destroy it. If a new one only spawns once, and has a check not to spawn another and use the old one it’d be best to keep it and just make it visible/invisible when needed. I can show you a specific BP on how to do all this once I see how your project handles the UI spawning. If this is a free example project, I can take a look into it directly if you’d prefer if you have the market link.

Did you mean that I will send it to you my project?

Oh no no no, I was asking if this project was from an example of some sort as I see it had some polish, if so I was going to snag it and work from that. Otherwise I can make a little video walking through how you could look through your blueprints if you don’t know how to. Just need to know how much I need to go through before going deep into a whole video.

PLAYER BP

Main_Menu_Level BP

GAMEMODEBASE BP

Awesome this is exactly what I needed! There’s 2 routes to go here. I personally like to go “scorched earth” and destroy all widgets when going back to the main menu, but sometimes you want a more surgical measure and only destroy one. I’ll show you both ways here so you can make that decision yourself and others that come across this in the future might be able to benefit from knowing both.


Surgical Method

So it looks like your controls are a UMG widget and attached via the player BP. Now the best move is to set the return value of that promote the Mobile Controls Widget to a variable.

Name it something like MobileControlsWidgetRef or something easily identifiable.

Find the pause menu widget and make a new variable, this is going to house the Mobile Controls Widget Ref on the pause widget so we can call from the widget itself easily.

Find where your pause menu widget is created in your player controller and set it’s variable when it spawns like this. (Sorry the variable names are really close together, I’d use different distinct names when you do yours so it doesn’t get confusing)

Then I’d make a custom event on the Pause widget BP to remove the controls widget from the viewport (this destroys it outright after a couple of second of garbage collection.)

And then on your pause menu widget BP, where it sets it to go to the main menu call the destroy event we made before and bam, all good.


Scorched Earth (also easy)

On your pause widget where you change to the main menu, you could do this number if your game doesn’t rely on retaining ANY widgets. Remove all widgets gets rid of ALL of them from the viewport so be careful with this one.


Let me know if you have any questions about either of these implementations!

1 Like

I did what you said. This is my PAUSE MENU WIDGET

And here is the pic when I go back to main menu level. I think the cause of problem here is this SPORTSCAR_PAWN is still exist. Is there a method to get rid of that pawn if I go back to main menu?

Could be, but I don’t think that’d be it here. Looks like it’s creating the main menu widget but not swapping levels at all so that should have worked. I thought your game loaded the main menu level again but it seems to just load the widget, which makes this a bit different. You’re right however if the car spawns it will run it’s begin play every time it spawns, and that’s what’s adding your widget to your screen again. That said it shouldn’t be spawning anything if the main menu is just a widget instead of going to the level itself which should reset all of that.

Just to make sure, there is no Open Level or Load Level node after the return to main menu bit right?

You could go into the world settings for the main menu level and just set a different default pawn, I usually just use a blank camera pawn to sit there for UI based stuff, or the main pawn back there (disabled) so it can initialize it before the game (which it looks like they did here).

Also it looks like you’re making a new Mobile controls widget when the pause menu is constructed. If the pause menu is constructed at all while the main menu is up that would make a new one each time. The reason I passed the reference when the player class made it was so it was the one universal.

Do you create a new pause menu every time it’s pressed? If so it’s making new mobile UI every time.

2 Likes

What I did is I set my Main-Menu-Level to blank spawn that fix my problem. Thank you so much sir.

2 Likes

Oops my problem still exist. I thought its okay already. I have a OPEN LEVEL node to return on menu. My bad, I uploaded a wrong pic of pause menu widget BP. This is the current BP of PAUSE MENU WIDGET.

When I press back to main menu the SPAWNCAR is there. I think that was the cause of my mobile controls appear and the engine sound I hear in the main menu level.

Is there a way to get rid of that spawn car If I go back to my main menu level? Please help me if there is a way of that.

Ahhh ok, gotcha. It’s all good, I was definitely a bit confused by the references there. So yes you’re right, if the car is there in the main menu and the car were to spawn the menu.

We could override the main menu’s world details to set the default pawn as empty, then you’ll just spawn as a camera in the main menu.

However from what you’re showing me here, the mobile controls widget is being spawned by your pause widget’s construct function. When is the pause menu widget spawned? When the level starts, or when the player first hits the pause button?.

This is what happened when I go back to my main menu

Alright, so I’ll walk you through the two issues here.

  1. Both your car and your pause widget are currently spawning mobile controls right now (unless you had changed the player between those posts). This means you have 2 mobile controls that spawn. I think you were intending to pass the mobile controls reference from the player to the pause widget, but you ended up spawning another one when the pause menu constructs.

Here:

and Here:

So delete the create mobile controls widget and add to viewport node on the pause menu widget, then go back to my original post it shows you how to pass the reference over so you don’t make a new one.

  1. The car spawning in the main menu. So from what you said you blanked out the default pawn class on the world details gamemode override in the menu right? Then something else is spawning the sports car in the main menu. I’d look around in your gamemodes, player controllers, and any blueprints that operate in your main menu. Once you find that I can show you how to disable it.

I tried to remove the mobile widget ref and my problem still exist. I’ll upload my all BP that connects in my main menu level here. I’m hoping for a fix.

MainMenu_GameMode BP

Main_Menu Controller BP

Main_Menu_Level BP

Main_Menu_Widget BP

Alright, so to make this easier with likely no major repercussions, we’re just going to go scorched earth right before the spawn of the main menu itself. This should get rid of all widgets besides the main menu even if the player car has to be spawned for game logic reasons. (I don’t think it does but I don’t want to possible cause problems for you down the line). In the main menu level blueprint, right after beginplay add a blank delay node (this makes a 1 frame delay) and then remove all widgets, then spawn the main menu widget and attach. Note: you will have to change this in the future if you want to make any UI before the main menu, but in this case it works perfectly for your example.

It fix my problem but the I can hear the engine sound in the main menu. Is there any ways to stop this ?

EDIT: I already fix it I just destroy the actor in my main menu level

Thanks for the help