Course contentsShow
← Unreal Engine Game Development
Lesson 741 of 88010. Networking and ReplicationFree lesson

Configuring Client-Side Actor Replication Settings

Adjust replication settings to control which actors are visible to specific clients based on their connection and proximity to the actor.

In this lesson, you will learn how to optimize network traffic by fine-tuning how the server determines which actors are relevant to specific clients.

By default, Unreal Engine uses "Network Relevancy," where the server tracks every replicated actor and decides if a client needs to know about it based on distance and priority. However, in complex scenes, sending updates for every actor in a player's range can quickly saturate bandwidth. You can optimize this by overriding IsNetRelevantFor in your AActor subclass.

Fine-Tuning Visibility

The IsNetRelevantFor function is the primary gatekeeper for replication. When the server iterates through connected clients to decide what to send, it calls this function for every relevant actor. You can implement custom logic here to ignore actors that are behind walls, too far away, or simply not important to that specific player's gameplay context.

bool AMyCustomActor::IsNetRelevantFor(const AActor* RealViewer, const AActor* ViewTarget, const FVector& SrcLocation) const
{
    // Always replicate to the owner
    if (this->GetOwner() == RealViewer) return true;

    // Custom logic: Only replicate if within a tighter custom radius
    float DistanceSquared = FVector::DistSquared(GetActorLocation(), ViewTarget->GetActorLocation());
    if (DistanceSquared > FMath::Square(CustomRelevancyDistance))
    {
        return false;
    }

    return Super::IsNetRelevantFor(RealViewer, ViewTarget, SrcLocation);
}

Proximity and Frequency

Beyond relevancy, you can adjust NetCullDistanceSquared in the Actor’s properties (accessible via GetNetCullDistanceSquared()). This acts as a hard limit for when an actor stops sending updates entirely. If an actor is further than this distance from the viewer, the server will stop replicating its properties to that client, saving CPU and bandwidth.

For static actors that don't need frequent updates even when visible, you can also manipulate NetUpdateFrequency. Reducing this value for background objects ensures that while they remain "visible" to the client, they consume significantly less of your limited network budget compared to high-priority items like the player character.

Key Takeaway: By overriding IsNetRelevantFor and configuring NetCullDistanceSquared, you take manual control over the server's replication pipeline, ensuring that only essential data reaches each client.