RealDocs

UGameplayStatics::CreatePlayerFromPlatformUser

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

Description

Creates a new local player identified by a platform user ID rather than a numeric controller index, enabling proper platform account association for console and PC online play. Returns the new PlayerController or null on failure.

Caveats & Gotchas

  • FPlatformUserId is platform-specific — on PC it often maps to the same value as a controller index, but on consoles it represents the signed-in account. Mixing CreatePlayer and CreatePlayerFromPlatformUser for the same physical controller can create duplicate local players.
  • If the FPlatformUserId is already associated with an existing local player, a new player will not be created and the function returns null.
  • Introduced in UE 5.1 as part of the online identity refactor; not available in 4.x or early 5.0 projects without backporting.

Signature

static ENGINE_API class APlayerController* CreatePlayerFromPlatformUser(const UObject* WorldContextObject, FPlatformUserId UserId, bool bSpawnPlayerController = true);

Parameters

Name Type Description Default
WorldContextObject const UObject* Any object in the world to use as context.
UserId FPlatformUserId The platform user ID to associate with the new player. Pass PLATFORMUSERID_NONE to use the next available ID.
bSpawnPlayerController bool Whether to immediately spawn a PlayerController for this player. true

Return Type

APlayerController*

Example

Create a player for a specific platform account C++
FPlatformUserId UserId = IPlatformInputDeviceMapper::Get().GetUserForInputDevice(ControllerId);
APlayerController* NewPC = UGameplayStatics::CreatePlayerFromPlatformUser(this, UserId, true);
if (NewPC)
{
    // Player is ready
}

Version History

Introduced in: 5.1

Version Status Notes
5.6 stable
5.1 stable Introduced as part of platform user ID refactor.

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.