APlayerState::OnSetUniqueId
#include "GameFramework/PlayerState.h"
Access: public
Specifiers: virtual
Description
Called on both server and client after UniqueId has been modified. Override to react to a player's unique ID being assigned or updated, for example to look up persistent account data.
Caveats & Gotchas
- • This is a virtual engine-called hook — do not call it directly. It fires from SetUniqueId and also from OnRep_UniqueId on clients, so any logic here executes on both authority and proxies.
- • At the time this is called, GetUniqueId() already returns the new value. You do not need to re-read from the parameter; there is none.
Signature
ENGINE_API virtual void OnSetUniqueId() Return Type
void Example
Fetch account data when a player's ID is assigned C++
void AMyPlayerState::OnSetUniqueId()
{
Super::OnSetUniqueId();
const FUniqueNetIdRepl& Id = GetUniqueId();
if (Id.IsValid())
{
FetchAccountData(Id);
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?