APlayerState::BP_GetUniqueId
#include "GameFramework/PlayerState.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallableENGINE_API
Description
Returns the online subsystem unique ID for this player. Consistent across all clients and servers when the player is logged into an online service.
Caveats & Gotchas
- • The returned FUniqueNetIdRepl may be invalid (IsValid() returns false) if the player is not logged into an online subsystem, such as in a LAN match with no Steam/EOS login.
- • This is the Blueprint-callable wrapper for the C++ GetUniqueId(). In C++ prefer GetUniqueId() which returns a const reference rather than a copy. The DisplayName in Blueprint is 'Get Unique Net Id'.
Signature
ENGINE_API FUniqueNetIdRepl BP_GetUniqueId() const; Return Type
FUniqueNetIdRepl Example
Store player unique ID for session tracking C++
void AMyGameMode::OnPlayerLoggedIn(APlayerController* PC)
{
if (APlayerState* PS = PC->GetPlayerState<APlayerState>())
{
FUniqueNetIdRepl UniqueId = PS->BP_GetUniqueId();
if (UniqueId.IsValid())
{
RegisterUniquePlayer(UniqueId);
}
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?