Closest path to volume


I’m trying to move a pawn to a volume. And that on the shortest route possible. That means the pawn should be moved to the closest point on the volume to the pawn.

I can find the closest point from the actor to the volume (getting the polys from the brush then Triangulate to get the triangles and check to find the closest point on each triangle to find the closest point to the complete brush). But when the pawn has to move around a corner to reach this point, then the closest point to volume might have changed.
I used something like this to move the actor to position 0 here.

            UPathFollowingComponent* PFollowComp = nullptr;

            const ANavigationData* NavData = NavSys->GetNavDataForProps((*Pawn)->GetController()->GetNavAgentPropertiesRef());
            FPathFindingQuery Query((*Pawn)->GetController(), *NavData, (*Pawn)->GetController()->GetNavAgentLocation(), FVector::ZeroVector);
            FPathFindingResult Result = NavSys->FindPathSync(Query);


You can let the path following component actually follow an actor. That actor may implement the INavAgent interface to let the PathFollowingComponent know its location. Unfortunately, the actor that’s trying to find the path is not passed along, so that I cannot find the closest point to the volume each time the volume is asked for it.
This is the NavAgent interface function I’m refering to:

	 *	Retrieves Agent's location
	virtual FVector GetNavAgentLocation() const PURE_VIRTUAL(INavAgentInterface::GetNavAgentLocation,return FVector::ZeroVector;);

Maybe I could subscribe to the PathFollowingComponent’s PostProcessMove delegate and update the destination each time, but that sounds rather expensive…

How would I accomplish my task? I’m currently not very optimistic of finding a solution. Though, I’m sure there must be one.

Something I have found is:


Though it seems to something for internal usage of calculating the nav mesh??