Do you use Set Input Mode Game Only node in your game? Have you experienced any strange behavior of a user input controller? If yes, stick with me, I am going to shed some light on how this function works under the hood.

Unreal Engine 4 has three input modes:

Game Only

UI Only

Game and UI.

In a couple of words, Game Only mode is for a game controller; UI Only mode is for UI, obviously; and Game and UI – is best suited for games with rich UI (e.g. a typical RTS). I won’t go into details – that’s not the purpose of this blog post. If you need info you may check this video – it is pretty helpful.

It covers pretty much everything you need to know. Except for one thing, though. And the author is missing it. It is Set Input Mode Game Only and how it is different from the UE4 default input mode.

Set Input Mode Game Only problem

When I was implementing a menu for my game I faced a problem similar to this one: https://answers.unrealengine.com/questions/420047/an-lmb-event-is-only-triggered-with-a-double-click.html

After quitting the menu and switching back to Game Only mode, I had to click twice or double click in order to get the mouse back to work. I tried using Set Input Mode Game and UI but that was not exactly what I wanted. Now the reason why Game Only mode did not work is that the mode is not exactly the default mode of UE4.

Let’s examine Project Settings -> Input section of a UE4 project. You will see that Default Viewport Mouse Capture Mode may have the following possible values:

A default value could be “Capture Permanently Including Initial Mouse Down” or another one. The problem, however, is that Set Input Mode Game Only resets this option to “Capture Permanently” value. And if it is not your default value, your game will run not as you expect.

The solution

Now let’s check the source code. Open WidgetBluprintLibrary.cpp and the method UWidgetBlueprintLibrary::SetInputMode_GameOnly

You see, that calling this method just creates a new object with no arguments and that is equal to setting Default Viewport Mouse Capture Mode to “Capture Permanently”. And if you need other values you will have to initialize input mode manually.

I made a small helper function in my player controller class. It is not universal but suits my needs perfectly. Have a look – it may be something you are looking for:

void MyPlayerController::SetInputModeGameOnly( bool InConsumeCaptureMouseDown) { FInputModeGameOnly InputMode; InputMode.SetConsumeCaptureMouseDown( InConsumeCaptureMouseDown); SetInputMode(InputMode); }