I have to be honest, I copied this code from the TopDown project. But with my code it dowsn’t work. Here is my code.
AMyAIController.cpp:
UNavigationSystem* const NavSys = world->GetNavigationSystem();
float const Distance = FVector::Dist(destLocation, character->GetActorLocation());
if (NavSys && (Distance > 120.0f))
{
NavSys->SimpleMoveToLocation(this, destLocation);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("condition is true")));
}
The screen debug message is always displayed, so I think my problem is with the function SimpleMoveToLocation().
How can I make my character move to destLocation?