Download

Simple replication question

Hi!!

I’m a multiplayer programming noob and I’m still a bit confused about some questions…

As far as I know the PlayerState class is replicated so… Should I mark my PlayerState variables as replicated or are all the variables automatically replicated??

Thanks

Original APlayerState variables are already automatically replicated.
You MUST mark your own variables that you wan’t to replicate as Replicated.
Also you have to define this method in your cpp:



void AYourPlayerStateClass::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);

	// For each variable that you marked as replicated add a DOREPLIFETIME call

        DOREPLIFETIME(AYourPlayerStateClass, YourReplicatedVariable);
}


You can use DOREPLIFETIME_CONDITION to do conditional replication.

Hi Sveitar,

thank you very much!! I already knew about the C++ stuff for replication but I did not know if Unreal replicates automatically all the variables inside replicated framework replicated classes.

Thanks to you I know it now :slight_smile:

Bye!