Set input mode UI only makes inputAxis Value stuck

I’ve experienced the exact issue today.

After digging into the C++ code of UE4, it turns out the engine will stop listening to all game-related registered input after calling SetInputModeUIOnly()


GameViewportClient.SetIgnoreInput(true);

Set the flag bIgnoreInput to true, will cause all the axis binding, action binding events be ignored, including the RELEASE event:



bool UGameViewportClient::InputAxis(FViewport* InViewport, int32 ControllerId, FKey Key, float Delta, float DeltaTime, int32 NumSamples, bool bGamepad)
{
if (IgnoreInput())
{
return false;
}

...


Since the RELEASE event is ignored, the key state (axis value) remains the same. That is probably why after changing to SetInputModeGameOnly() the character keeps moving in the same direction until you press the relevant key again (update the old axis value).

A workaround for me is to call


PlayerController->PlayerInput->FlushPressedKeys();

after SetInputModeUIOnly() to manually reset the value of all axis bindings and action bindings.

After some test runs, this method seems to fix the issue for me.

I know this is an old post, however, I hope this could help people who experienced the same problem.

Hopefully, this issue is resolved in later versions of UE.

11 Likes