Server to client replication delay

Hello, I’ve got a question regarding variable replication. I created a SpectatorPawn, which is possessed by a player as soon as he dies. Since it’s not a free-to-fly spectator, but a spectator mode, where you can only observe your teammates (similar to Counter-Strike) I’ve put two replicated variables into my Custom Player State holding the current postition and the current rotation of the player pawn, the playerstate is connected to. The replication itself does work and I’m able to observe another player. The problem, however, is that the SpectatorPawn only gets the updated variables once per second, which causes major “lag” in the camera movement. See this:

This only happens, when a client is the observer. If the server is observing another player the location and rotation get updated very smoothly. See this:

So basically the client versions of my Spectator Pawn only get updates every second. Why is this?

Here are my cpp files and the associated blueprints:

SpectatorPawn


void AShooterSpectatorPawn::OnStartFire()
 {
     ++iIndex;
     ObservablePawns.Reset();
     for (int32 i = 0; i < GetWorld()->GameState->PlayerArray.Num(); ++i)
     {
         AShooterPlayerState* plState = Cast<AShooterPlayerState>(GetWorld()->GameState->PlayerArray*);
         AShooterCharacter* Pawn = Cast<AShooterCharacter>(plState->StatePawn);
         if (!plState->bIsABot)
         {
             if (Pawn)
             {
                 /* See if the Pawn is still alive */
                 if (Pawn->IsAlive())
                 {
                     /* If yes add it to observable pawns */
                     ObservablePawns.Add(Pawn);
                     ObservablePSs.Add(plState);
                 }
             }
         }
     }
 
     if (ObservablePawns.Num() > 0)
     {
         /* Make sure you loop through the observable array and don't run beyond it */
         if (iIndex >= ObservablePawns.Num())
         {
             iIndex = 0;
         }    
 
         GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Yellow, TEXT("Index: ") + FString::FromInt(iIndex));
         ObservedPawn = ObservablePawns[iIndex];
         ObservedPlayerState = ObservablePSs[iIndex];
     }
 }

MyPlayerState.h


     UPROPERTY(Replicated, VisibleAnywhere, BlueprintReadWrite, Category = PlayerPawn)
         FVector MyLocation;
 
     UPROPERTY(Replicated, VisibleAnywhere, BlueprintReadWrite, Category = PlayerPawn)
         FRotator MyRotation;


MyPlayerState.cpp


 void AShooterPlayerState::GetLifetimeReplicatedProps( TArray< FLifetimeProperty > & OutLifetimeProps ) const
 {
     Super::GetLifetimeReplicatedProps( OutLifetimeProps );
 
     DOREPLIFETIME(AShooterPlayerState, TeamNumber);
     DOREPLIFETIME(AShooterPlayerState, NumKills);
     DOREPLIFETIME(AShooterPlayerState, NumDeaths);
     DOREPLIFETIME(AShooterPlayerState, MyRotation);
     DOREPLIFETIME(AShooterPlayerState, MyLocation);
     DOREPLIFETIME(AShooterPlayerState, StatePawn);
 }


PlayerPawn-Blueprint:

If any of you guys had an idea, that’d be nice, since I don’t know where my error is.

Thanks Max

Hi Max,

Just throwing something out into the air here (I’m not too familiar with blueprint yet) but shouldn’t you interpolate and use the delta passed from Event Tick?