Pause / Un-Pause with same key not working

Hello Unreal community!

I’m having an issue that I’ve been racking my brain on for a bit now and I figured before I head to bed I’d ask for a new set of eyes. Basically the issue is the game pauses and the menu comes up as normal. Using the resume button works as well as the quit button. What I’m wanting to do is add the functionality of being able to unpause the game with the same key using the “FlipFlop” node.

I was almost 100% certain this would work but it’s not working as intended. I know it’s partially working because if I use the “Resume Game” button then hit pause again the cursor disappears as it should.

Can anyone possibly give me some input on why this might not be working as expected?

Try having a variable that changes between true and false when the player pauses/unpauses the game. For example, have a boolean variable that changes to true when the esc key is hit for the first time then will change to false when the player clicks the resume button AND/OR when the player hits esc the second time. Instead of having a flipflop, have a branch that checks the variable. If the player hits esc, have it check to see if it’s true or false. If its true, execute the code to unpause the game, then change it to false. If it’s false, execute the code to pause the game then change to true. Make sure that the variable changes to false when the resume button is clicked too.

Try that and let me know if you are still experiencing problems!

I think BP_Character doesn’t receive input when you use Set Input Mode UI Only. Does the event on BP_Character even fire once the game is paused?

You probably need to grab the key input in your menu and close it and unpause from there.

1 Like

I tried this method and got the same result.

I’ve followed this path and was able to find some more information on how to override the input in the widget blueprint BUT in all the other examples the GetKey Function has an execute pin and mine does not and cannot figure out why.

If I remove the Set Input Modes entirely I get the desired result but then can no longer use the mouse to interact with the menu.

You can’t add it directly without overriding the “OnKeyDown” function in the Widget Blueprint which is the graph you see above. The attached image is from another person with a similar issue and apparently achieved the desired results.

Some nodes have both a “pure” and … well, I don’t know what the other kind are called, I’ll call it impure, but I think I made that up. Casts work the same way. The only difference is the ones with the execution pin (the impure ones) allow you to control what happens based on whether or not it failed. With a pure node, it just gets evaluated when it’s needed, in your case when the Branch gets to execution. This means that if it fails, you just access none, and you can’t do anything about it, since you can’t redirect execution based on it failing. In your case, this is perfectly fine, because the On Key Down function should never fire with an invalid In Key Event.

What happens when you add the Escape key event (the same one you’re using in BP_Character) in your widget? Does it not fire?

Aha, I understand now. Out of curiosity, what’s the thread you found that on? I’m planning to do something similar on my own project soon and would like to read it.

When you set your blueprints up the way that image shows, does On Key Down ever fire? What’s the NOTE on the branch?

Now I see what you mean about Get Key being different in yours than in the screenshot. Did you drag Get Key off the In Key Event Pin, or add it by right clicking? Try dragging the pin off if you didn’t.

I know I’m late to the party and this may be an obvious suggestion, but did you try setting the ‘execute when paused’ option on the pause input node?

5 Likes

This is the correct answer, thank you

Ah, the classics! Thanks for the reminder :slight_smile:

Thanks, this is what I was looking for :slight_smile:

worked for me thanks