Simple Inventory: InputMode Flip Flops when using CommonUI, BP_GetDesiredInputConfig and CommonActivatableWidgetStack

Summary

I’m trying to make a relatively simple game with an inventory.
A button you press to to open it. And then from the inventory you can access some “sub pages”.

I’m trying to build this using CommonUI to handle the input, when to change game mode etc. But I’m running into issues.

Implementation Details

I have a Active widget on the screen, this widget overrides the function BP_GetDesiredInputConfig.
It sets the capture mode to “Capture Permanently”
On that widget there is a “CommonActivatableWidgetStack”

I can press a button to push a new widget on that stack, lets call it “Inventory”.

This widget also overrides BP_GetDesiredInputConfig.
But this time to set the capture mode to “No Capture” and ignore Move & Look.

So far so good.

From the “Inventory” I can open a sub page. E.g. “Bag”. This just pushes a new widget on the same stack.
“Bag” has the same BP_GetDesiredInputConfig as “Inventory”

When the swap is animated, you regain the Move & Look input and the mouse is captured for a short time (animation length).
And then the mouse gets repositioned to the center of the screen.

This is undesirable.

What I tried:

  • This also happens even if animation speed is 0.
  • I could also not use the Stack component but I want the “inventory” to go away when “bag” is open. So it seems perfect.
  • Adding and removing things from the viewport directly might work but then those would block input to the “Root” and use that to capture some keypresses.

My theory:
It’s probably because the first widget gets deactivated first, resetting to “Root” widgets settings. And then after a bit “Bag” gets activated.


Currently I feel the only way to get this to work would be to reimplement those parts in c++ and try to replace the behavior that way.
I’m I missing something? This seems like a common thing to build. How do people solve it?

EDIT: Didn’t work. Does not reset to “Game” Mode.
I think I found a solution for now:

If I only override “BP_GetDesiredInputConfig” in the root widget. And return the correct value depending on if there is something in the stack or not. Then it seems to work as I want it.

Horray.

New trick:

Added a empty Widget to the stack that has the “Game Mode” as desired input
The Root has the “Menu mode”.

This seems to work now.

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