RealDocs

UNavigationSystemV1::GetRandomReachablePointInRadius

function NavigationSystem Blueprint Since unknown
#include "NavigationSystem.h"
Access: public Specifiers: const

Description

Returns a random NavMesh point that is reachable from Origin within the given radius. Returns false if no valid point was found.

Signature

NAVIGATIONSYSTEM_API bool GetRandomReachablePointInRadius(const FVector& Origin, float Radius, FNavLocation& ResultLocation, ANavigationData* NavData = NULL, FSharedConstNavQueryFilter QueryFilter = NULL) const

Parameters

Name Type Description Default
Origin const FVector& World-space center of the search area.
Radius float Search radius in world units.
ResultLocation FNavLocation& Output location that is reachable on the NavMesh.
NavData ANavigationData* Specific nav data to use. Pass NULL to use the default NavMesh. NULL
QueryFilter FSharedConstNavQueryFilter Optional query filter for area costs. NULL

Return Type

bool

Caveats & Gotchas

  • The Blueprint-exposed equivalent is K2_GetRandomReachablePointInRadius, which outputs an FVector rather than FNavLocation.
  • The returned point is reachable in the navigation sense (on navmesh, within radius), not necessarily in a straight line from Origin.
  • May fail if the NavMesh is not built in the area or Radius is too small.

Example

Pick a random patrol point near the AI C++
UNavigationSystemV1* NavSys = FNavigationSystem::GetCurrent<UNavigationSystemV1>(GetWorld());
FNavLocation ResultLoc;
if (NavSys && NavSys->GetRandomReachablePointInRadius(GetActorLocation(), 1000.f, ResultLoc))
{
    MoveToLocation(ResultLoc.Location);
}

Version History

Introduced in: unknown

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.