Replication for late joiner

How should I handle replication to late joiners? Replicated actors should automatically replicate all the values (replicated ones) from server to a newcomer, right? But this is not happening in my case. I still have a variables setup on server and everything is empty on connected client.

This variable is set on server, and when client appears this appears as empty one. Also Actor is marked as always relevant owned by Player Controller that runs server.

UPROPERTY(BlueprintReadWrite, EditAnywhere, ReplicatedUsing = OnRep_BaseMapInfo)
FStreamingLevelInfo BaseMapInfo;

I’m kinda sure that those actors are ‘connected’ cuz later RPCs are executed. This happens ofc in shipped build, when I connect by Steam.

I’ve always defined Replicated in the UPROPERTY macro alongside ReplicatedUsing. i.e.

UPROPERTY(Replicated, ReplicatedUsing=OnRep_func)

though I’m not sure this is what your issue is? The next question would be, are you setting the property to replicate in GetLifetimeReplicatedProps, and if so, are you setting any conditions that might be stopping it from replicating? Also do you call the super in GetLifetimeReplicatedProps, that one often slips my net.

Stick a UE_LOG in the onrep to confirm if your OnRep fires when you connect. If it doesn’t then it’s probably one of the above reasons.

I’ve added the replicated to property definition even though I’m not sure if it is needed. It has no effect on behavior. The rest looks as you described:

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

	DOREPLIFETIME(ASublevelManager, BaseMapInfo);
	DOREPLIFETIME(ASublevelManager, FullSublevelsList);
}

Sorry I just reread your original question noticed you say

Also Actor is marked as always relevant owned by Player Controller that runs server.

Player controllers don’t replicate to non-owners. That is, every client only has 1 player controller on their side. The server will hold all player controllers but only replicate to owners.

If you’re running a listen server then the servers own player controller will never replicate to anyone else. If you’re running a dedicated server then the server won’t (or shouldn’t) have an instance of its own controller in the first place.

On yet another glance I see you say it’s just an actor owned by the controller, not the controller itself,. The only other thing I can think of is your BaseMapInfo seems like it’s a struct? I believe struct properties need to be defined as UPROPERTY to replicate… but beyond that, there’s not much else to go on. You could try forcibly fetching the variables through an RPC on begin play with some checks to only execute it on remote clients, but this shouldn’t really be necessary.

Found the issue but dunno how to fix it. The problem is with TArray of custom structure, the moment when it exceeds some size threshold the whole actor stops to replicate its values. I can’t even send this data through RPC, the RPC is simply not delivered to the client. During the test, I had 700 records in the array. Any solution from you guys? Why Unreal is blocking something like this…

Also, this happened only in Shipping build, but in Development build looks like it enables it.

UPROPERTY(BlueprintReadWrite, EditAnywhere, ReplicatedUsing = OnRep_FullSublevels, Replicated)
TArray<FStreamingLevelInfo> FullSublevelsList;

USTRUCT(BlueprintType)
struct FStreamingLevelInfo
{
	GENERATED_USTRUCT_BODY()

public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Default")
	FString MapName;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Default")
	FString PackageName;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Default")
	FVector SpawnLocation;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Default")
	FRotator SpawnRotation;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Default")
	int32 LevelId = -1;
};

check your bandwidth settings in the config.

Found the solution… Looks like the array exceeds the max possible replication size or that is my assumption. I’m updating data from this array in chunks and that fixed the problem.