Nodes for walkability check in RecastGraph

Hey,

Just a quick question, I am currently just using grid graphs in most scenarios at the moment as I am in prototyping phase, however I am sure when I go to production I will probably want to use the RecastGraph (I have pro so may as well make use of it).

However one of the things I was wondering was how you test walkability, as normally you would get nearest node and check if it is walkable, however in a grid you are gonna have nodes in a fairly uniform manner, however I was wondering if you need to do things differently for Recasts or mesh type graphs.

The scenario would be something like a tower defense style game, so given a point you would want to check to see if it is walkable so a unit can be placed.

Hi

Generally in a recast graph, everything represented by it is walkable. You can make individual triangles unwalkable, but usually you just remove that part of the navmesh instead. See http://www.arongranberg.com/2013/08/navmesh-cutting/

In a Tower Defence game I would actually recommend you to use a grid graph. Tower defence games are usually naturally grid based, so a grid graph makes the most sense.

1 Like

Ok let me change tact, lets say I have a large city based level and I am using a recast graph. Then I need to add functionality to let people build things in various places, a simple way for me to know if something can be built is to check if that position is within a walkable zone.

So given the above scenario what code would you implement given a RecastGraph and a Position (Vector3) to work out if you can build/walk on that position (or if you cannot the closest walkable position to it?)

Hi

You can use the RecastGraph.PointOnNavmesh method.
See http://arongranberg.com/astar/docs/class_pathfinding_1_1_recast_graph.php#aeed4ad546cd5203f76f68d77f9969647

Like this:

`
RecastGraph graph = AstarPath.active.astarData.recastGraph;

if ( graph.PointOnNavmesh ( transform.position, null ) != null ) {
Debug.Log (“Inside the walkable zone”);
}`

This method does not seem to exist for me on a RecastGraph, I am on the latest version to my knowledge.

Hi

If it didnt, try updating to 3.4.0.6 which definitely includes it.