Get UNavigationSystemV1 properly

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;
}

What I am doing wrong?

NavLocation is a Fstructure, not need to create w/ new.
just declare as:

FNavLocation NavLocation;
auto NavSystem = UNavigationSystemV1::GetNavigationSystem(GetWorld());
NavSystem->GetRandomPointInNavigableRadius(PawnLocation, 1000, NavLocation);

them you can used NavLocation.Location, not - >,use the dot. cause is a Fstructure.

this:


	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;

and this:

const FVector TargetLocation = BlackboardComponent->GetValueAsVector(Destination.SelectedKeyName);