Get Pawn from Owner

I am trying to get the Actor Location but I am getting the “[C2352] ‘AController::GetPawn’: illegal call of non-static member function” error.

I am brand new in C++, what I am missing?

EBTNodeResult::Type UBTTask_GetRandomLocation::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
	auto PawnLocation = AController::GetPawn()->GetActorLocation();
	auto BlackBoard = OwnerComp.GetBlackboardComponent();
	
	auto NavLocation = new FNavLocation();

	UNavigationSystemV1::GetRandomPointInNavigableRadius(PawnLocation, 1000, *NavLocation);

	FName BB_Target = "TargetPosition";
	BlackBoard->GetValueAsVector(BB_Target) = NavLocation->Location;
		
	return EBTNodeResult::Succeeded;
}

It seems GetPawn() is not a static method. You probably need to pass in a controller instance and then call ->GetPawn() on it.

You’re trying to call the function of an abstract class, whereas you need to call the function of a concrete instance of the controller.
You need to get the reference to the actual controller first.

My question was misleading, sorry about it.

since it is a task for BehaviourTress, I need to reach the Pawn from the OwnerComp.GetOwner(), not from a concrete class.

My knowledge of Unreals API is limited atm. Do you have an idea how can I do it?

I don’t need the Pawn, instead I can Use

OwnerComp.GetOwner()->GetActorLocation();