Replication Graph and spectator relevancy

What’s the best way to have a spectating client share the same list of relevant actors as it’s view target using the replication graph? With the legacy method I simply proxied my IsNetRelevantFor call through my view target when spectating which worked perfectly.

I’ve tried the following code in my GatherActorListsForConnection() implementation, but got some unusual behavior.


// If we are spectating, copy our view target's ReplicationActorList.
if (PC != Params.Viewer.ViewTarget->GetOwner())
{
  if (APlayerController* ViewTargetPlayerController = Cast<APlayerController>(Params.Viewer.ViewTarget->GetOwner()))
  {
    if (UGASReplicationGraphNode_AlwaysRelevant_ForConnection* ViewTargetNode = GASGraph->GetAlwaysRelevantNode(ViewTargetPlayerController))
    {
      UE_LOG(LogGASReplicationGraph, Verbose, TEXT("Copying ReplicationActorList from %s to %s"), *ViewTargetPlayerController->GetName(), *PC->GetName());
      Params.OutGatheredReplicationLists.AddReplicationActorList(ViewTargetNode->ReplicationActorList);
    }
  }
}

2 Likes

[USER=“292853”]Get Gooder[/USER] did you ever figure out a solution for this?

I fixed the problem I had in my game (which sounds similar to yours @Get_Gooder). You only have to set the view target on the spectating view controller.

The problem I had is that I only did that on the client. You also have to set the view target on the player controller on the server, because that is the view target used by the replication system to determine where the player is in the world for the purposes of network location relevancy.