Closing UI Menu Doesn't Go Back to Game

Hi, I’m trying to make the menu for my game but I’m having a few issues with it.

The first issue is that when I open the menu, my key presses still cause events to happen in the game instead of the menu until I use the mouse to click one of the buttons in the menu, then I can use buttons or my controller to navigate the menu. When I’m IN the menu however, both before AND after I click in the menu, I can still click and drag to make my character look around, and use input keys or controller to move and do other things.

The second issue is that when I press a key to open a menu, for example pressing the M key to open the map menu, and then click on another tab in the menu, for example Inventory, using my mouse or the 'next/previous tab key, I can still press the M button to close the menu, when I should only be able to close it with the escape button or the I (inventory) button, but that doesn’t close it properly, instead the menu does close but my mouse is still visible and my character doesn’t look around when I move the mouse, instead I have to click and drag to look around, I can still walk and use the other keys though.

The third issue is that when I open a menu, for example the Map menu again, click on the inventory, then press I to close it, if I then press one of the menu buttons again for example I to reopen the inventory, if I then press another menu key to open another tab the first press will do nothing, but the second will open a second menu and the first one will be stuck on the screen. This even happens if after reopening the menu I close the menu again, and then open it again and try press another menu key, it doesn’t matter how many times I open and close the menu in between, it always starts reopening more.

A fourth issue is more of a minor inconvenience, when I’m in the menu I can’t move my mouse beyond the game windows borders.

Here is what I think are the important bits of code, if you need to see the rest just let me know. Thanks!

This first image is in the ThirdPersonCharacter blueprint

This second image is from inside the Game Menu widget blueprint.

I think your work around for the navigation menu is confusing, did you follow a video tutorial for this, could you share the link? actually i have never used “Set active widget index”, so i have to investigate why you are using it, i never trigger each sub menu UI widget from Player BP, only main menu, sub menus should be loaded from main menu widget; but i can see there is 2 “Remove from parent” nodes, wich you haven´t connected to anything, and “Target” should be connected to “Create Game Menu Widget” if not, they do nothing;

But i think your biggest issue, wich causes most of your problems, and makes you create branches to find out if main widget is open or closed… is that, in order to stop the game from running and pressing other buttons or moving while your menu is open, you need to use “Set Game Paused” node and check it to true, this should be triggered by your menu InputAction Button, then connect it to trigger the main menu widget; to unpause, press the same input button for a second time, it should select “Set Game Paused” node, but now “false”, you can do this using a “Flip Flop” node.

“Set Game Paused” is going to freeze the game, to avoid players confusing menu buttons with play buttons, just remember:::::::::: to select that Input button node, then, in the “details” panel, check “Execute when paused” if not you won´t be able to use that button while paused, to unpause. But, this wont work, if you keep using player to trigger each menu UI, because sub menus, should be triggered from main menu Widget. After you pause the game, so now not any play button will be triggered, unless you set those Inputs to trigger something inside the main menu widget.

I attached a picture
pausebeforemenu.png

That won’t work for my game unfortunately, I’m making an MMO so the game can’t be paused.

I didn’t follow any tutorial, I’ve followed a few widget blueprint tutorials in the past for various things, and thought I’d give it a go with everything I’ve learned, I thought I did quite well to get this far tbh, haha, it’s actually all really organised too, I have separate input buttons for different menu tabs, all a part of the same ‘game menu’. The ‘Game Menu’ input is for controller so it all goes to 1 menu and remembers which one was closed last to reopen, the rest of the inputs are PC specific and open their each respective menu.

The ‘Active Widget Index’ is a parameter of the ‘Widget Switcher’ in the Widget designer. The Widget Switcher acts as a parent, and then you add widgets as children to the widget switcher, and they are all automatically assigned a number depending on where they’re placed in the layers tab, so the top one would have an widget index value of 0, the second would be 1, and so on. The ‘Set Active Widget Index’ basically hides all other widgets that are children to the widget switcher, and only shows the one that is assigned to the active value. Great for menu systems.

Also the ‘Remove from Parent’ nodes are in the widget blueprint so the target to remove is itself.

Here’s the full blueprint inside the widget blueprint if it makes it any easier to understand.

Anyone able to help? I’ve still not managed to figure it out

I had a similar issue and i solved it with “Set Show Mouse Cursor” variable, also you can try to “remove all widgets” for your third issue, and then create again the widget or something.

Hope it helps.

I’m already using the ‘Set Show Mouse Cursor’ variable in the first screenshot. And I replaced the ‘Remove from Parent’ nodes with the ‘Remove All Widgets’ nodes in both the Third Person Character blueprint, and the Game Menu Widget blueprint, tried both itterations, but replacing them in the Game Menu Widget blueprint didn’t make a difference, and replacing them in the Third Person Character blueprint made the menu close every time I pressed one of the other menu keys while in the menu, so I couldn’t navigate tabs using the keys since it just closed the menu every time.

Bump…

For anyone stumbling across this - this exact portion of OP’s problem can likely be solved by the following code on the PlayerController (unfortunately I don’t know the equivalent blueprint):

SetInputMode(FInputModeGameOnly());

… this would be placed, e.g., at the end of the function closing the menu.


As an aside, if you encounter this issue after transitioning from a main menu with, e.g., using a MainMenuPlayerController to a [OpenLevel/RealGame]PlayerController where the InputMode was not initially set (so, for example, if you open the game level in the editor the player may be able to look around, but when transitioning from a menu screen to a game level they might lose this ability unless the player holds left-mouse button), you may be able to solve this problem by placing the aforementioned code after Super::BeginPlay() on the PlayerController.

Documentation:
APlayerController::SetInputMode | Unreal Engine Documentation

FInputModeDataBase | Unreal Engine Documentation