How to get FVector return in C++ from BP equivalent GetRandomReachablePointInRadius?

Hi, could someone please paste and example in C++ how to get FVector return from GetRandomReachablePointInRadius. In BPs there is return FVector RandomLocation. In C++ code I can see only bool return functions and deprecated FVector return. It is very confusing and I can’t find an answer online. Many Thanks in advance for your time.

In C++ a function cannot return more than one value, so the way to do it is to pass a variable by reference as an argument and then modify the value of it inside the function

If you declare a blueprint exposed function in C++ with a parameter that is a reference, the blueprint system will automatically assume it’s an output, and will create a return pin for it

In your case, the signature of the function is (if you call the blueprint version of it):

static bool K2_GetRandomReachablePointInRadius(UObject* WorldContextObject, const FVector& Origin, FVector& RandomLocation, float Radius, ANavigationData* NavData = NULL, TSubclassOf<UNavigationQueryFilter> FilterClass = NULL)

as you can see, FVector& RandomLocation is passed by reference (&), and is the one that will hold the random point when the function returns.

So you can, as an example, use this like this (assuming we call this from an actor):

const FVector OriginLocation = GetActorLocation();

FVector RandomLocation;
bool bRandomLocationFound = UNavigationSystemV1::K2_GetRandomReachablePointInRadius(this, OriginLocation, RandomLocation, 500);

if (bRandomLocationFound)
{
    // Do what you want with RandomLocation here, it wil hold the random point
}

Thank you for detailed explanation. Now I understand what I was looking at.