Hi, I’m currently trying to understand how CharacterMovementComponent works.
From my understanding, UCharacterMovementComponent::ClientUpdatePositionAfterServerUpdate
is used when client and server moves diverge and a correction issued from the server is necessary. Here’s my question: why is it that the character reproduces any moves sent from the server instead of the server simply directly updating the characters position, velocity, acceleration, movement state, etc.? Wouldn’t this be a simpler solution or am I misunderstanding something?
Specifically, I’m interested about this part:
// Replay moves that have not yet been acked.
UE_LOG(LogNetPlayerMovement, Verbose, TEXT("ClientUpdatePositionAfterServerUpdate Replaying %d Moves, starting at Timestamp %f"), ClientData->SavedMoves.Num(), ClientData->SavedMoves[0]->TimeStamp);
for (int32 i=0; i<ClientData->SavedMoves.Num(); i++)
{
FSavedMove_Character* const CurrentMove = ClientData->SavedMoves[i].Get();
checkSlow(CurrentMove != nullptr);
CurrentMove->PrepMoveFor(CharacterOwner);
MoveAutonomous(CurrentMove->TimeStamp, CurrentMove->DeltaTime, CurrentMove->GetCompressedFlags(), CurrentMove->Acceleration);
CurrentMove->PostUpdate(CharacterOwner, FSavedMove_Character::PostUpdate_Replay);
}