UGameplayStatics::SetPlayerPlatformUserId
#include "Kismet/GameplayStatics.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintCallable
Description
Associates a platform user account ID with a local PlayerController, used to link online identity (achievements, cloud saves) to a specific local player slot.
Caveats & Gotchas
- • Introduced in UE 5.1 alongside the platform user ID refactor. Not available in earlier engine versions.
- • Only applies to local PlayerControllers. There is no validation that the UserId is currently signed in — passing an invalid ID will silently succeed but break any downstream online subsystem calls that rely on the association.
- • Changing the UserId after online sessions have started can desync leaderboard and achievement reporting for that player.
Signature
static ENGINE_API void SetPlayerPlatformUserId(APlayerController* PlayerController, FPlatformUserId UserId); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| PlayerController | APlayerController* | The local PlayerController to update. | — |
| UserId | FPlatformUserId | The platform user ID to assign to this player. | — |
Return Type
void Example
Reassign platform identity after a user sign-in event C++
void AMyGameMode::OnUserLoggedIn(FPlatformUserId NewUserId)
{
APlayerController* PC = UGameplayStatics::GetPlayerController(this, 0);
if (PC)
{
UGameplayStatics::SetPlayerPlatformUserId(PC, NewUserId);
}
} Version History
Introduced in: 5.1
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
| 5.1 | stable | Introduced with platform user ID refactor. |
Feedback
Was this helpful?