Old thread, but this is still very relevant. I’ve combined a few solutions to come up something that works well for me:
First, swap the controls: This uses the Enhanced Input Subsystem (otherwise, you’ll have to use something like Disable Input). We swap between the default controls and a new set of controls made just for the pause menu by adding/removing input mapping contexts. This allows us to leverage the same IA_PauseMenu
event (see the image at the bottom), meaning we can set our input mapping contexts to show & hide the menu with the same key.
Second, handle showing the mouse: We show/hide the mouse cursor, then we do some other config magic to ensure that there aren’t any focus issues that commonly happen here. I got these nodes from this video, which was extremely helpful in understanding why they’re needed here. NOTE: Using Shift/Tab to toggle the menu may also cause focus issues. Either use a different key or try this solution.
Last, set the UI’s visibility: We can now simply show the menu by setting the widget’s visibility to visible
. When setting the menu to visible, I also borrowed some logic from here that centers the mouse cursor for you.
I have this function directly in my player controller, which I call like this: