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.
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?
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?
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.
Let’s say we have a random Input-Enabled actor using the 1 button, consuming it:
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:
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 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.
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.