Need advice on an input key that does multiple things contextually.

I want the Escape key on the keyboard to perform several things depending on the situation the player is in:

  1. In the title screen, do nothing (let the menu widget be drawn permanently)
  2. In game mode, it opens the game’s Main Menu
  3. When talking to a character in dialog mode, it will just cancel the dialog
  4. In generic dialog prompts, it’s basically a generic shortcut to the “Cancel” or “Close” buttons
  5. In character stats display, it will be used as a generic “back” function for multi-page menus

A further challenge is that these situations must all be mutually exclusive, as in - if the player is in dialog mode, pressing Escape should NOT open the Main Menu.

I am currently checking for the Escape key via an Input Event in the PlayerController - with Switch statements.

So my question is, is this the best way to do it or not? Because I am finding it difficult to manage the Blueprint when I dump so many specific checks inside the PlayerController.

Did You Know?
You can have more than one Event Graph in a blueprint.

I believe you are handling it in probably the best-case scenario that could be done in such a situation. If you want to make it easier to manage, you could offload-it to another Event Graph and your main one won’t be so overwhelming.

make enumerator that describes game state.
make variable in player controller that tracks game state, update it every time you change game state.

then on ESC event do select from enum (or something like this), you will get node with separate execution pin for each state.

You can pack it all into nice interface or event dispatcher, but first make that above raw version.

And use “Sequence” it makes nice split of graphs out of that long sphagetti code snakes
Then you can put each branch into separate function

Very good advices Yggdrasil and Nawrot… these have given me some ideas. Thanks!