When I press the Escape key in my Unreal Engine project, it triggers functions in both my Pawn class (ABall) and my HUD class (ABallGameHUD), causing unexpected behavior.

I have a game with a Pawn (ABall) and a HUD (ABallGameHUD). When the game is running, I press the Escape key, which should open a pause menu UI and set the input mode to UI only. However, when I press the Escape key again to close the UI, the input handling results in both the Pawn and HUD class functions being executed simultaneously. This unintended behavior disrupts the expected flow of pausing and unpausing the game.

Attempts to Resolve:
I’ve tried various solutions, including introducing state management, using boolean flags to track the UI’s open/closed state, and modifying the input handling in both classes. However, none of these attempts have successfully resolved the issue.

Desired Outcome:
I’m looking for guidance on how to handle the input and UI interaction properly to ensure that pressing the Escape key:

Opens the pause menu UI.
Sets the input mode to UI only.
Closes the UI.
Restores the input mode to the game.
Ensures that only one class handles the input and UI actions at any given time, preventing simultaneous execution.
Additional Information:
Both my classes, ABall and ABallGameHUD, are involved in handling input and UI interactions, and I need a structured approach to manage these actions effectively without conflicts.

1 Like

You can inherit from the player controller. Keep everything as is, except write your own escape handler. Then, you can decide which other blueprints to send the signal to.

1 Like

alternatively take a look at enhanced input. is more involved but has input priority.

1 Like

@ClockworkOcean
Confirm this will you?

Isnt making sure you set the consume input flag on one or the other bleurpint enough to “solve” the issue?

3 Likes

I confirm it :slight_smile:

You could fiddle around with ‘consume input’, but if you let your player controller handle ESC, it’s a focal point for the whole operation.

I use it in my latest game ( I have not blessed the world with it yet :rofl: ), because ESC can mean many things, depending on the context.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.