Hi, I am trying to get UNavigationSystemV1 → GetRandomPointInNavigableRadius. My IDE doesn’t complain about it, but doesn’t allow me to compile. This is my method:
EBTNodeResult::Type UBTTask_GetRandomLocation::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
auto PawnLocation = OwnerComp.GetOwner()->GetActorLocation();
auto BlackBoard = OwnerComp.GetBlackboardComponent();
auto NavLocation = new FNavLocation();
auto NavSystem = UNavigationSystemV1::GetNavigationSystem(GetWorld());
NavSystem->GetRandomPointInNavigableRadius(PawnLocation, 1000, *NavLocation);
const FName BB_Target = "TargetPosition";
BlackBoard->GetValueAsVector(BB_Target) = NavLocation->Location;
return EBTNodeResult::Succeeded;
}
UWorld* World = NPC->GetWorld();
if (!IsValid(World))return;
UNavigationSystemBase* NavigationSystemBase = World->GetNavigationSystem();
if (!IsValid(NavigationSystemBase))return;
UNavigationSystemV1 *NavSyste = Cast<UNavigationSystemV1>(NavigationSystemBase);
if (!IsValid(NavSyste)) return;