Trying to open/close a UMG menu widget with the keyboard and running into trouble.
Setup is starting with a FPS BP template, which has a First Person Character blueprint and Game Mode blueprint.
Someone suggested creating a custom PlayerController blueprint and doing things in there, but it doesn’t seem to work any differently than doing things in the Character blueprint (correct me if wrong).
- Create the ‘Menu’ widget blueprint with some clickable buttons, I started from the Pause Menu tutorial but not too important the details since I am focusing on keyboard input for now.
- Go to Edit > Project Settings > Engine > Input > Bindings, add ‘ToggleMenu’ ActionMapping and bind to a Key (e.g. M).
- In the Character or PlayerController blueprint, add the ‘ToggleMenu’ action node and accomplish the following:
- Set ‘Input Mode UI Only’: this is to disable player controls such as movement (WASD) or jump (Space)
- Show mouse
- Create menu and assign to viewport so it is visible
What I would like now is that the same key binding to ToggleMenu (M) will effect the menu to close:
- Set ‘Input Mode Game Only’: make so the player can move again
- Hide mouse
- Detach menu from viewport so it is hidden
But this doesn’t appear to be possible because:
- When ‘Input Mode UI Only’ is set, the ‘ToggleMenu’ action in the player controller will no longer fire when the binding key (M) is pressed. So apparently the menu cannot be closed from the Character or PlayerController blueprint.
- Inside the ‘Menu’ widget blueprint, it is not possible to add the ‘ToggleMenu’ action.
So, how can I trigger the ToggleMenu action to close the Menu using the key that was bound (M)? Some suggestions I have seen is to scan for keyboard input in the Menu widget, but that would not respect the binding (M) set in the Project Settings, correct?