APlayerState::OnRep_UniqueId
#include "GameFramework/PlayerState.h"
Access: public
Specifiers: virtualUFUNCTION
Description
Replication notification called on clients when the UniqueId (FUniqueNetIdRepl) is first replicated. The base implementation calls RegisterPlayerWithSession to associate the player with the online session on the receiving client.
Caveats & Gotchas
- • The base implementation calls RegisterPlayerWithSession, which interacts with the Online Subsystem. If you override without calling Super, online presence and session membership may not be correctly reflected on non-server clients.
- • UniqueId can be invalid (IsValid() == false) for LAN or offline games. Always check GetUniqueId().IsValid() before passing it to Online Subsystem functions.
- • The FUniqueNetIdRepl type wraps an FUniqueNetId but is replication-friendly and platform-opaque. Do not assume a specific format or cast the inner ID without checking the subsystem type.
Signature
ENGINE_API virtual void OnRep_UniqueId(); Return Type
void Example
Load per-player cloud save data once UniqueId arrives C++
void AMyPlayerState::OnRep_UniqueId()
{
Super::OnRep_UniqueId(); // Calls RegisterPlayerWithSession
const FUniqueNetIdRepl& NetId = GetUniqueId();
if (NetId.IsValid())
{
UMySaveGameSubsystem* SaveSystem = GetGameInstance()->GetSubsystem<UMySaveGameSubsystem>();
SaveSystem->LoadCloudDataForPlayer(NetId);
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?