RealDocs

UGameplayStatics::GetPlayerControllerFromID

function Engine Blueprint Since 4.14
#include "Kismet/GameplayStatics.h"
Access: public Specifiers: staticBlueprintPure

Description

Returns the local player controller associated with the given physical input controller ID. Useful for local multiplayer to map hardware input devices to player controllers.

Caveats & Gotchas

  • Only works for local players — remote player controllers do not have a physical controller ID accessible on this machine, and this function will not return them.
  • Controller IDs are assigned by the operating system and input subsystem; they may not be contiguous or start at 0 after controllers are disconnected and reconnected.
  • Prefer GetPlayerControllerFromPlatformUser on platforms that use FPlatformUserId, as hardware controller IDs are deprecated in favour of platform user abstractions in UE5.

Signature

static ENGINE_API class APlayerController* GetPlayerControllerFromID(const UObject* WorldContextObject, int32 ControllerID);

Parameters

Name Type Description Default
WorldContextObject const UObject* Object used to retrieve the world context.
ControllerID int32 Physical controller ID as reported by the input system (e.g., gamepad slot 0, 1, 2).

Return Type

APlayerController*

Example

Handle a controller-connected event and find its player C++
void AMyGameMode::OnControllerConnected(int32 ControllerId)
{
    APlayerController* PC = UGameplayStatics::GetPlayerControllerFromID(this, ControllerId);
    if (!PC)
    {
        // No player assigned yet — create one for split-screen
        UGameplayStatics::CreatePlayer(this, ControllerId, true);
    }
}

Version History

Introduced in: 4.14

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.