Getting a walkable point on Recast graph to place a seeker

Hi there.

I need to get a random point on a recast graph to place a seeker, that will not overlap with the surrounding items. I can get the walkable nodes of the graph using RecastGraph.GetNodes() and checking with the Walkable attribute on that nodes, and then get random points on that nodes calling PathUtilities.GetPointsOnNodes(). However the latter one can give me points very close to obstacles, where my character (seeker) collides (overlaps) with the obstacles.

Any help is appreciated!

Hi

On a recast graph, the intended way to configure it is so that every point on the navmesh is a valid position for the character (that should not collider with the walls). Try increasing the ‘character radius’ parameter in the recast graph settings.

Thanks for your prompt reply!

So the generated points are actually calculated taking into account the radius? I mean if there are NavMeshCuts set on my obstacles, my random points will be offsetted from that cuts by that radius .

Thanks.

Hi

Navmesh cuts cut straight through the navmesh. They are not offset, they are assumed to be a bit larger than the actual obstacles. Normal obstacles that are detected when the graph is scanned are offset using the radius however.

1 Like

Unfortunately, sometimes PathUtilities.GetPointsOnNodes() gives me points inside my obstacles (NavMesh cuts).

Am I missing something?

That sounds odd. Do you think you could post a screenshot?
Do you have a TileHandlerHelper component somewhere in your scene? One such component is required to make navmesh cuts work.

I’m sorry, but I can’t post a screenshot.

Yes , I have a game object on my scene and TileHandlerHelper is attached to that gameobject.
Is there a chance that the RecastGraph is not yet scanned when I’m trying to get that random points on nodes? Though I’m using Generate Cache button from Save & Load on my A* gameobject before running the game.

Maybe you are doing it before the navmesh cuts have been processed. Try inserting a wait before you query for the points.

Seems that solved the problem.
I appreciate your help and time!