Replication Graph Fast Shared Path Starting Guide

Replication Graph Fast Shared Path Starting Guide

Article written by Alex K.

One of the features provided by the Replication Graph is the option to set a Fast Shared Replication Path for certain actors. The fast shared path is a way to create an actor’s serialization data once and reuse it to all connections that replicate this actor on the same frame. This article seeks to provide a basic example and overview of how to set up the fast shared path for an actor in a Replication Graph.

While any actor can implement a fast shared path for replication, a common use is for replicating a pawn’s movement data. Instead of serializing and recompressing the movement data multiple times for each connection, the fast shared path can instead just serialize it once and append the pre-serialized bits directly into the packets.

To create a FastShared path for a pawn’s movement data, the first step is to define a custom struct containing all the data needed for the movement update. This struct should define a custom NetSerialize function and support shared serialization (see NetSerialization.h for more info on custom struct serialization).

The pawn using this struct can then implement a function that first fills the struct’s data before sending it as the parameter of an unreliable multicast RPC. This unreliable multicast RPC is how the Replication Graph will serialize and send the struct to all clients. One thing to note is that when the FastShared path is used, normal property replication is skipped, so on net updates where a Replication Graph node decides that the FastShared path should be used for an actor, the only properties clients will receive for that actor will be the parameters of this multicast RPC.

Next, the Replication Graph needs to set the function and function name for the fast shared path in the pawn’s replication info. For example:

PawnClassRepInfo.FastSharedReplicationFunc = [](AActor* Actor)
    bool bSuccess = false;
    if (AMyPawn* Pawn = Cast<AMyPawn>(Actor))
        bSuccess = Pawn->UpdateSharedReplication();
    return bSuccess;

Finally, the pawn should be routed into a replication list that sets the EActorRepListTypeFlags::FastShared flag. A common node that does this is UReplicationGraphNode_ActorListFrequencyBuckets (when its DefaultSettings.EnableFastPath is true).

Again, using the FastShared path for replicating movement info is just a common use case. Depending on the needs of a project, any actor can implement its own struct and fast shared replication function, and any node can route actors into a fast shared list.

Get more answers on the Knowledge Base!


Thank you Joe for the wonderful writeup, it does shine more light on this really exciting feature.

As the whole process is a bit more complex, would it be possible to get more code snippets or possibly example project about replicating the character movement?

The main area of interest is the custom struct and it’s processing at UpdateSharedReplication. I am not certain how to inject the struct back to character movement without any hacky calls.

Thank you

1 Like