Pause menu opening and closing || On key down in widget

So I am making a singleplayer game, I want to make it so that if i press lets say escape a pause menu will pop-up and when you press the same button again it disappears. So I was searching around for something to help me with my pause menu and found a video by Virtus. Now it wasnt the video that helped me it was a comment by Keytotruth. He had a more efficient way to do the thing in the video (Which btw didnt work for me the things in the video).

Keytotruth came up with this:

Now this didnt work for me as you will see in my image, probably because of the “get key”. You see, I used a different “Get key” as mr. keytotruth did, but i cant find the one he used so thats why I post this question because i can find it… (Yes I am very new to the UE4 landscape, but i know i did something wrong)

P.S. The picture I took does not have the Exec. pin plugged in, that isnt the problem, i tested it with but it still didnt work, also I made the widget focusable.

I think both of those ways are incredibly convoluted for something as simple as a pause menu if you know what key you want to pause and unpause your game. Here is a different solution. Be sure to check the box on the keyboard event (whichever one you select to execute this code) to have it receive input when paused.

1 Like

Okey, ill give that a try! Thanks dor the help Nebula, it means a lot!

Hey Nebula, I tried to copy what you are doing and came up with this. There is only one little problem, it doesnt work. When I tried to press P inside of the pause menu it didnt go back.

(I have put this inside of my player character blueprint, maybe that has something to do with it?)

1 Like

What happens when you press P? Does it open up the pause menu? If yes did you make sure that you allowed “P” event to still receive input while game is paused? (See screen shot above, select the “P” event node and make sure that the box under the ‘input’ tab is checked to “execute while paused”

Also I noticed that you placed your input to be “UI Only” this will prevent keyboard input. “P” is a keyboard event so it works the first time opens the menu and after that it will only accept input from the UI so basically clicking buttons. You can’t do that if you want a keyboard event to toggle the pause menu. The whole point of having it “pause” the game is that even if you press a keyboard button that gives game input like W,A,S,D for movement, it won’t execute while paused. So it is redundant to set input mode to UI only AND pause the game. Get rid of that node, make sure keyboard input is allowed for the “P” key while paused as I mentioned above and it should work fine.