Download

Single key pause/unpause trouble. What is blocking input?

Hi,
I am trying to use a single key to pause/unpause the game. There is a million answers for this problem already through google - I assure you I’ve tried them all and nothing is working.

I’ve also copied code from the Action RPG example project, where the intended function does work, but it won’t work in my own project.

The idea is that the same key which pauses also unpauses. The problem is that input is blocked while paused.

Checking “execute while paused” on the input key makes no difference. Using “listen for input” on the widget is not working. Calling an event to pause on the game instance like shown in the action RPG template is not working… I’ve tried different combinations of “game mode/game and ui/ui only” to no avail.

It works in the action Rpg template but not in my game… what could be the difference? Worst case I just require players to click a button to resume, but who wants to do that in 2021?

I think the problem is something to do with the input priority stack…

any advice would be appreciated. I’d like to provide an answer for this problem once and for all because it is asked 1,000 times since 2015 and I still can’t find a solution.

This works:

Obviously if you switch to UI only, the Player Controller’s 1 input will not fire. Are you using UI only mode?

In my project that same code does not work. Once paused no input is read.

I am not using UI only mode.

If you’re on version other than 4.25 (I am), drop the above script in an empty project and see how it behaves. At least we’ll know if it’s version dependant (a bug perhaps) or if it’s the project’s settings that are the culprit.

I am not using UI only mode.

Other than that, could you show how you pause the game?

I’ll try an empty project.

It is working the the Action RPG example on 4.26. I only have 4.26 installed.

How I am pausing the game: I have tried every way I can think of. Nothing is working. Your example is something I’ve tried, like mentioned in OP I have tried calling it different ways from different places…

I have a number of actors and widgets in the game… I wonder if somehow something is stealing input or something?

Quite possible. Widgets get priority in the Game and UI mode. Do you override the pausing input in a widget: onKeyDown → Handled

So in an empty project it works as expected (using same code as you above).

But not in my game project. So probably is one of the widgets then.

I haven’t done anything special in the widgets…nothing related to input that I know of. I guess I’ll have to go through each of them but I am not sure what I am looking for.

I tried removing all actors except the player and also not creating any widgets - still no effect there.

Do you use that key anywhere else? Or is this key dedicated to Pausing / Unpausing only?

I’ve tried many different keys…

I just made a blank level in this project and tested. It works there. So there must be an actor in the level that is getting in the way?

Here’s the priority list:

image

Which blueprint does the pausing?


Let’s say we have a random Input-Enabled actor using the 1 button, consuming it:

image

Neither the player controller, the LB or the Pawn will process that input. Only other Input-Enabled actors with higher priority can get to it first:

image

That’s the reason why I’ve been preaching about not enabling input in actors - it’s disabled by default and for a good reason. Not saying that’s the case here but it’s a common trap.

I am pausing from the player character blueprint right now. Earlier I tried by sending an event to game instance.

And it is working in an empty scene.

Several blueprint actors get spawned on being play and attached to the character. However I think we can rule them out because in an empty scene where just the player and these actors exist, pause/unpause works.

The other actors in the game shouldn’t be having anything to do with input… but I’ll duplicate the scene, delete them, and see what happens.

Okay, really weird. Maybe the level itself is hosed up somehow.

I tried duplicating the level and it crashes unreal. Tried that three times and crashes.

So I made an empty level and just copy/pasted everything from the old level to the new one. Now pause/unpause is working…

I think we could only say that there is something corrupt in the level? I have taken all content, pasted into a new one, and everything works.

Levels have higher priority that the Pawn, so if the level consumes key input, the Pawn can’t get it.

image

On the levels default settings, this is the relevant part? It is the same on both levels.

Afaik, this is irrelevant for the LB.

I believe that the thing to look for is whether you’re using the same key elsewhere.

I am pausing from the player character blueprint right now

Is there perhaps more than 1 character? Are we doing some possessing / unpossessing?

yeah it is same key, same blueprint…only one character.

but i think i just narrowed down further. The one thing that is different between two levels is the game mode override.

Perhaps something in the player controller then. THat is the only part of the game mode where i have made any changes.

Okay so if i switch to the default player controller in the game mode overide, it works.

AFAIK the only changes I have made to the PC is that I enabled mouse events though. I’ll just have to go through and see if there is any other difference i gues.

1 Like

Okay, I think we’ve got it solved…

I reset everything on the player controller to default and now it works… the weird thing was, the only values that were different is that I had it set to tick while paused. Unticking that seems like the opposite of what you’d want to do here, but… it works now.

Awesome sauce. Thanks for the update!

1 Like