Download

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?