Hi all. I have some questions about UCharacterMovementComponent
Why are we need to use the function : UCharacterMovementComponent::ClientUpdatePositionAfterServerUpdate for call SavedMoves again?
Do we not have used them earlier in ReplicateMoveToServer ? + we get some corrections later in ClientAdjustPosition_Implementation:
// Trust the server's positioning.
UpdatedComponent->SetWorldLocation(WorldShiftedNewLocation, false);
Velocity = NewVelocity;
// Trust the server's movement mode
UPrimitiveComponent* PreviousBase = CharacterOwner->GetMovementBase();
ApplyNetworkMovementMode(ServerMovementMode);
Why are we use ClientUpdatePositionAfterServerUpdate after this ?
The place(ClientAdjustPosition_Implementation) where ClientData->bUpdatePosition is set to = true also call ClientData->AckMove(MoveIndex) = deleted all Moves and then in ClientUpdatePositionAfterServerUpdate :
// Replay moves that have not yet been acked.
for (int32 i=0; i<ClientData->SavedMoves.Num(); i++)
{
const FSavedMovePtr& CurrentMove = ClientData->SavedMoves*;
CurrentMove->PrepMoveFor(CharacterOwner);
MoveAutonomous(CurrentMove->TimeStamp, CurrentMove->DeltaTime, CurrentMove->GetCompressedFlags(), CurrentMove->Acceleration);
CurrentMove->PostUpdate(CharacterOwner, FSavedMove_Character::PostUpdate_Replay);
}
But before this function we deleted all of these SavedMoves! Saved only 1 in LastAckedMove, but this LastAckedMove is not part of the ClientData->SavedMoves
Is it deleting all, right?
// And finally cull all of those, so only the unacknowledged moves remain in SavedMoves.
const bool bAllowShrinking = false;
SavedMoves.RemoveAt(0, AckedMoveIndex + 1, bAllowShrinking);
AckedMoveIndex - last element, then AckedMoveIndex + 1 = all
In what cases it can call these movements?
Or maybe I confuse something…