UGameplayStatics::GetPlayerControllerFromPlatformUser
#include "Kismet/GameplayStatics.h"
Access: public
Specifiers: staticBlueprintPure
Description
Returns the local player controller associated with the given FPlatformUserId. This is the UE5 successor to GetPlayerControllerFromID, using the platform user abstraction layer instead of raw hardware controller IDs.
Caveats & Gotchas
- • Only works for local players; remote players have no FPlatformUserId accessible on another machine.
- • FPlatformUserId is distinct from both the hardware controller ID and the online unique player ID — use IPlatformInputDeviceMapper::Get() to convert between them.
- • An invalid FPlatformUserId (PLATFORMUSERID_NONE) returns null without error; always validate the ID from the input device event before passing it in.
Signature
static ENGINE_API APlayerController* GetPlayerControllerFromPlatformUser(const UObject* WorldContextObject, FPlatformUserId UserId); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| WorldContextObject | const UObject* | Object used to retrieve the world context. | — |
| UserId | FPlatformUserId | Platform-level user identifier (e.g., from IPlatformInputDeviceMapper or FInputDeviceConnectionChangeData). | — |
Return Type
APlayerController* Example
Route an input device event to the correct player controller C++
void AMyGameMode::HandleInputDeviceConnected(FPlatformUserId UserId)
{
APlayerController* PC = UGameplayStatics::GetPlayerControllerFromPlatformUser(this, UserId);
if (!PC)
{
// New platform user — create a player for split-screen
UGameplayStatics::CreatePlayerFromPlatformUser(this, UserId, true);
}
} Tags
Version History
Introduced in: 5.1
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?