Set Input Mode Game and UI disables game input

Hello everyone. I’m trying to create some dialogue widgets in my game that can be used alongside the actual gameplay. It’s a 2D game, so I want dialogue boxes to appear while the player is still able to move around and so forth. The dialogue boxes will be controlled with different keys to the ones used to move the character in game, so there’s no control confusion.

I thought this would be doable with the Set Input Mode Game and UI node, but when I use this, control is taken away from the game and only works in the widget. When I click outside of the widget, control returns to the game but is taken away from the dialogue box. I want the player to be able to control both at once eg. hit the “continue” key on the dialogue box while continuing to move through the level.

I should also note that I am using widget components to create the dialogue boxes, but as far as I know the controls for the widget class should work the same.

Any help would be greatly appreciated.

Hi.

So it’s probably safe to assume that either one can have the focus at once but not both.

That said, nothing stops you from retaining a variable to your widget currently in viewport and capturing the key presses in the game e.g. player controller, and then acting on the widget by either calling into it from the player controller, or better, using variable binding from the widget into the player controller.

So first, when you create the widget and add it to viewport, save it to a variable in your player controller, game mode or wherever.

Then In the widget, if it’s about position, you can bind the position to a function which taps into the game mode, player controller or wherever. Otherwise the key captures in the player controller can call function in the widget or act on the widget directly.

Hope this helps :slight_smile:

Thanks for your answer . So do you think my best option is to create some custom events/functions in the widget blueprint, and call those events via the NPC that the player is talking to? (The NPC actor is what spawns the widget in the first place)