UGameplayStatics::GetPlayerStateFromUniqueNetId
#include "Kismet/GameplayStatics.h"
Access: public
Specifiers: staticBlueprintPure
Description
Finds and returns the APlayerState whose unique online ID matches the given FUniqueNetIdRepl, or null if no match is found. Works on both client and server.
Caveats & Gotchas
- • FUniqueNetIdRepl is the replicated wrapper around the platform-specific FUniqueNetId; comparing raw FUniqueNetId pointers directly will not produce the same results.
- • On a client, only player states that have been replicated are searchable — players who joined after a client-side latency spike may not appear until the next replication update.
- • An invalid or default-constructed FUniqueNetIdRepl (IsValid() == false) will always return null; validate the ID before calling.
Signature
static ENGINE_API class APlayerState* GetPlayerStateFromUniqueNetId(const UObject* WorldContextObject, const FUniqueNetIdRepl& UniqueId); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| WorldContextObject | const UObject* | Object used to retrieve the world context. | — |
| UniqueId | const FUniqueNetIdRepl& | The online unique ID of the player to look up. Obtained from APlayerState::GetUniqueId() or the Online Subsystem. | — |
Return Type
APlayerState* Example
Look up a player state by online ID from a ban list C++
FUniqueNetIdRepl BannedId = GetBannedPlayerId(); // your lookup
APlayerState* PS = UGameplayStatics::GetPlayerStateFromUniqueNetId(this, BannedId);
if (PS)
{
APlayerController* PC = Cast<APlayerController>(PS->GetOwner());
if (PC) PC->ClientWasKicked(FText::FromString(TEXT("Banned")));
} Tags
Version History
Introduced in: 5.1
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?