Does UE4 optimize TArray Properties Replication already?

Does UE4 optimize TArray Properties Replication already?
I uses TArray to store the list of player items. If player got many items, will add or remove items in the TArray cause the whole TArray elements copy to Client?

I can not find out the really working flows of TArray Properties Replications.
I hope some guys could help me figue out it or explain it.

Sorry for my poor English. You don’t understand, please point it out.

I’m worried about the performance of TArray Properties Replications.

If it has performance problems, I think I should implement add, remove in RPC.

If it works like you said.
How can I know which element of TArray is add, remove, or changed?

The only way I got in my head is that in OnRep_ function, compare the old TArray with the new just replicated TArray.
Am I wrong?

There is a way to get the old value of a replicated variable. Just pass an argument of the same type to the OnRep_Function() like this


/** declaration of a replciated actor array*/
UPROPERTY(Transient, BlueprintReadOnly, ReplicatedUsing = OnRep_Array)
TArray<class AActor*> ReplicatedActors;


void AYourActor::OnRep_Array(TArray<class AActor*> PreReplicationArray)
{
	//ReplicatedActors has already been replicated as this point.
        //PreReplicationArray has the values pre-replication.
}


1 Like