Download

Replication Graph Player States

In unreal’s example of a replication graph in the Shooter Project, player states are handled in a seperate node on the graph that limits the amount of Player States that return to the replication driver each frame. Here is the relevant code:


for (TActorIterator<APlayerState> It(GetWorld()); It; ++It)
    {
        APlayerState* PS = *It;
        if (IsActorValidForReplicationGather(PS) == false)
        {
            continue;
        }

        if (CurrentList->Num() >= TargetActorsPerFrame)
        {
            ReplicationActorLists.AddDefaulted();
            CurrentList = &ReplicationActorLists.Last(); 
            CurrentList->PrepareForWrite();
        }

        CurrentList->Add(PS);
    }    

*TargetActorsPerFrame *is set to 2 player states per frame in the shooter project and my question is why 2?
2 states per frame seems like quite a small number for a game with let’s say 200 connections then again I feel that increasing the number will lower network performance.

Player States don’t really hold onto values which change very often (typically anyway). Player names and stats etc, don’t update often and aren’t really important to the minute-to-minute gameplay - you’re better off spending those cycles on movement for example. For ShooterGame it makes perfect sense, since there’s nothing that’s relevant to other players to gameplay.

You want to be sending as few actors as possible each frame. We’ve throttled player states pretty hard too for a 100-player game.