Basically MoveToActor will call a bunch of other functions in the AIController which in a nutshell finds the path and sets some data. Then in the MovementComponent will eventually call RequestDirectMove every tick.
This next part isn’t important to understand I just thought it would be nice addition.
Here is the function that eventually calls RequestDirectMove
void UPathFollowingComponent::FollowPathSegment(float DeltaTime)
{
if (!Path.IsValid() || MovementComp == nullptr)
{
return;
}
const FVector CurrentLocation = MovementComp->GetActorFeetLocation();
const FVector CurrentTarget = GetCurrentTargetLocation();
const bool bAccelerationBased = MovementComp->UseAccelerationForPathFollowing();
if (bAccelerationBased)
{
CurrentMoveInput = (CurrentTarget - CurrentLocation).GetSafeNormal();
if (MoveSegmentStartIndex >= DecelerationSegmentIndex)
{
const FVector PathEnd = Path->GetEndLocation();
const float DistToEndSq = FVector::DistSquared(CurrentLocation, PathEnd);
const bool bShouldDecelerate = DistToEndSq < FMath::Square(CachedBrakingDistance);
if (bShouldDecelerate)
{
const float SpeedPct = FMath::Clamp(FMath::Sqrt(DistToEndSq) / CachedBrakingDistance, 0.0f, 1.0f);
CurrentMoveInput *= SpeedPct;
}
}
PostProcessMove.ExecuteIfBound(this, CurrentMoveInput);
MovementComp->RequestPathMove(CurrentMoveInput);
}
else
{
FVector MoveVelocity = (CurrentTarget - CurrentLocation) / DeltaTime;
const int32 LastSegmentStartIndex = Path->GetPathPoints().Num() - 2;
const bool bNotFollowingLastSegment = (MoveSegmentStartIndex < LastSegmentStartIndex);
PostProcessMove.ExecuteIfBound(this, MoveVelocity);
MovementComp->RequestDirectMove(MoveVelocity, bNotFollowingLastSegment);
}
}
Here at the very last line is where that RequestDirectMove finally gets called.