Why this function is always returning false?
I can’t understand, I have a nav mesh right on the player start position… I add NavigationSystem to build file cs.
So what is missing?
void UCubeGeneration::BeginPlay()
{
Super::BeginPlay();
UWorld* world = GetWorld();
if (world) {
UE_LOG(LogTemp, Log, TEXT("Got world. Now trying to find nav area for random loc..."));
UNavigationSystemV1* NavigationArea = FNavigationSystem::GetCurrent<UNavigationSystemV1>(this);
if (NavigationArea) {
UE_LOG(LogTemp, Log, TEXT("Found nav area"));
const FVector startPosi = world->GetFirstPlayerController()->GetPawn()->GetActorLocation();
UE_LOG(LogTemp, Error, TEXT("Test navArea: %s"), *NavigationArea->GetPathName());
FNavLocation endPosition;
UE_LOG(LogTemp, Error, TEXT("Start position: %s"), *startPosi.ToString());
if (NavigationArea->GetRandomReachablePointInRadius(startPosi, 1.f, endPosition)) {
UE_LOG(LogTemp, Error, TEXT("Found new random loc: %s"), *endPosition.Location.ToString());
}
else {
UE_LOG(LogTemp, Error, TEXT("Random loc failed!"));
}
}
else {
UE_LOG(LogTemp, Error, TEXT("Couldn't get nav area!"));
}
}
else {
UE_LOG(LogTemp, Error, TEXT("Couldn't get world!"));
}
}