I thought initially it was PlayerState, but that’s replicated to all clients, and I want to store “sensitive” information like health and spawn info that others dont need to know. I then thought PlayerController, but theres no way to call that on the server because its unique to each client. Is there a class that’s both available to the server and unique to each client, so I can safely manipulate data on it knowing that only that player will receive it?
You can have replication conditions like.
DOREPLIFETIME_CONDITION(AClassName, VarName, COND_OwnerOnly);
You can have this in the PlayerState class so other clients wont have access to its values.
PlayerState, but set the replication to owner only.
void AMyPlayerState::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AMyPlayerState, bSomethingEveryoneShouldGet);
DOREPLIFETIME_CONDITION(AMyPlayerState, bSomethingTheOwnerShouldNoGet, COND_SkipOwner);
DOREPLIFETIME_CONDITION(AMyPlayerState, bSomethingOnlyTheOwnerShouldGet, COND_OwnerOnly); <= this one.
}
Brilliant, thanks for the responses.