RealDocs

APlayerState::GetUniqueId

function Engine Since 4.0
#include "GameFramework/PlayerState.h"
Access: public Specifiers: const

Description

Returns a const reference to the player's online unique ID, which is consistent across all clients and servers when the player is logged in to an online subsystem.

Caveats & Gotchas

  • The returned reference is valid only as long as the PlayerState object lives. Do not store the reference across frames — cache the value as FUniqueNetIdRepl if you need it beyond the current callsite.
  • May return an invalid (empty) FUniqueNetIdRepl for LAN matches, offline play, or before the online subsystem has assigned an ID. Always call IsValid() on the result before using it.

Signature

const FUniqueNetIdRepl& GetUniqueId() const

Return Type

const FUniqueNetIdRepl&

Example

Identify a player by their online ID C++
const FUniqueNetIdRepl& PlayerId = PlayerState->GetUniqueId();
if (PlayerId.IsValid())
{
    UE_LOG(LogGame, Log, TEXT("Player unique ID: %s"), *PlayerId.ToString());
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.