if (UNavigationPath* NavPath = UNavigationSystemV1::FindPathToLocationSynchronously(this, ControlledPawn->GetActorLocation(), CachedDestination))
{
Spline->ClearSplinePoints();
for (const FVector& PointLoc : NavPath->PathPoints)
{
Spline->AddSplinePoint(PointLoc, ESplineCoordinateSpace::World);
//DrawDebugSphere(GetWorld(), PointLoc, 8.f, 8, FColor::Green, false, 5.f); //Creates debug speheres to show SplinePoints
}
if (NavPath->PathPoints.Num() > 0)
{
CachedDestination = NavPath->PathPoints[NavPath->PathPoints.Num() -1]; // Added if to fix out of bound error
bAutoRunning = true;
}
}