if (HasAuthority())
{
// B - A
// ----------------------------------- -----------------
// Direction = TargetLocation + GetActorLocation() - GetActorLocation()
FVector Direction = TargetLocation.GetSafeNormal();
FVector DistanceOffset = Direction * Speed * DeltaSeconds;
SetActorLocation(GetActorLocation() + DistanceOffset);
}
TargetLocation is in local space (relative to the moving platform). To move it into world space we can add the moving platform’s location.
But since we’re calculating B - A for direction, the + GetActorLocation() and - GetActorLocation() cancel out, and we can simply use a normalized TargetLocation as our local space direction.
Scale it by speed and delta time and add it to GetActorLocation() to get the result.