What's the difference between GetRandomReachablePointInRadius and GetRandomPointInNavigableRadius? In which case we should use which.

I think that this the difference:

  • GetRandomReachablePointInRadius : Return a random valid point within a radius which that specific actor can reach
  • GetRandomPointInNavigableRadius: Returns a random valid point within a navigable area, but not necessarily one which the actor can actually reach (i.e. it could be on an island)

Hi everyone,

I am trying to find a location on navmesh.

I tried both GetRandomReachablePointInRadius and GetRandomPointInNavigableRadius.

I’ve noticed these two functions won’t give me a location on navmesh sometimes (maybe because it fails).

So I call ProjectPointToNavigation on the out location given by these two functions which will give me a location on navmesh if it succeeds.

But sometimes the ProjectPointToNavigation fails on the out location given by GetRandomReachablePointInRadius but succeeds on the location given by GetRandomPointInNavigableRadius.

So I am confused about the difference between these two functions? And how I should choose between them.

Thanks in advance.

Yuchen

Thanks a lot, that’s the comments for these two functions but it doesn’t make much sense to me I am afraid.

I am a little confused what a valid point means and what a navigable area means.

I assume they both mean the point should be on the navmesh but it’s not always from my tests.

Could you provide some examples of their differences, please?

There is no clear description on what makes a point navigable but not reachable and vice versa.

Let’s assume you have your map and some boxes around on it. You also have a narrow path surrounded by boxes. It’s so narrow that if a character is slightly larger than a standard character, it won’t be able to squeeze and get through. You create the nav mesh and it calculates the obstructions. You place your AI on the map within the limits of the nav mesh, setup the move/patrol task and hit play.

If you used the “navigable” one, you’ll get a random point on the nav mesh, it could be anywhere. That could be on the narrow path which is considered navigable by the nav mesh. But the AI won’t be able to reach there.

Using the “reachable” one will not generate a point on those kind of places.

Thanks a lot for the explanation.

So I guess GetRandomPointInNavigableRadius = GetRandomPointInNavigableRadius + reachable check.

I’ve done some tests on these two functions and noticed that sometimes these functions return false (which could due to no navmesh in the radius) but even they return true, the navlocations given by them can NOT be projected to the navmesh sometimes (ProjectPointToNavigation returns false).

Do you have any ideas on why this is happening?

I have no clue. Closest I get is this topic.

OK, after some investigations and tests. I think I’ve got the idea.

So bool UNavigationSystem::GetRandomPointInNavigableRadius(const FVector& Origin, float Radius, FNavLocation& ResultLocation, ANavigationData* NavData, FSharedConstNavQueryFilter QueryFilter) const

will return a point on navmesh if succeed, but it doesn’t check whether the point is on a connected navmesh which the Origin (first parameter) is on.

So bool UNavigationSystem::GetRandomReachablePointInRadius(const FVector& Origin, float Radius, FNavLocation& ResultLocation, ANavigationData* NavData, FSharedConstNavQueryFilter QueryFilter) const

will return a point on navmesh if succeed, and it will make sure the point in on a connected navmesh with the Origin.

So if the Origin is off navmesh and we want to find a point on navmesh, we need to use GetRandomPointInNavigableRadius.

If the Origin is on navmesh and we want to find a point to move to, we can use GetRandomReachablePointInRadius.

3 Likes

Did you figure out why sometimes GetRandomReachablePointInRadius return false even if there is a valid nav mesh in the radius and it is connected ?