Unreal Engine 5 · Blueprint → C++
Set Input Mode Game Only in Unreal Engine 5 C++
The Set Input Mode Game Only Blueprint node maps to constructing an FInputModeGameOnly struct and passing it to APlayerController::SetInputMode() in C++.
Blueprint node & C++ equivalent

#include "Kismet/GameplayStatics.h"
// Get player controller
APlayerController* PlayerController = UGameplayStatics::GetPlayerController(this, 0);
if (PlayerController)
{
// Set input mode
FInputModeGameOnly InputMode;
PlayerController->SetInputMode(InputMode);
}What does Set Input Mode Game Only do?
It routes all input to the game (the player pawn and controller) and away from any UI widgets. This is the mode used during normal gameplay where the mouse controls the camera rather than a cursor.
It typically hides or captures the mouse cursor so it stays locked to the game viewport.
The C++ equivalent
Get the player controller with UGameplayStatics::GetPlayerController(this, 0) from Kismet/GameplayStatics.h, then create an FInputModeGameOnly instance and pass it to PlayerController->SetInputMode(InputMode). Always null-check the controller first.
FInputModeGameOnly is a lightweight struct with no required configuration, so default construction is enough for most cases.
When to use it
Call this when closing a menu or pause screen to return control to the player. Pair it with SetShowMouseCursor(false) if you also need to hide the cursor.
Use Game And UI instead if you want both the game and an on-screen widget to receive input simultaneously.
Frequently asked questions
How do you set input mode to game only in UE5 C++?+
Create an FInputModeGameOnly struct and call PlayerController->SetInputMode(InputMode). Get the controller from UGameplayStatics::GetPlayerController(this, 0).
What header do I need for FInputModeGameOnly?+
FInputModeGameOnly is declared in the engine's GameFramework headers and is normally already available through APlayerController. The snippet only adds Kismet/GameplayStatics.h for GetPlayerController; no extra include is usually needed for the struct.