How do you use the canTraverse method?

I’m not sure how to put the node I’m interested in into the method. I know the node I’m after as I have the exact vector3 coordinates for it but I’m not sure how to identify it as it’s stored as an int3. I tried casting its position as an int3 but had no success.

Hi

The CanTraverse method on the Path class?
That should usually not be used by external scripts.

If you want to check if a node can be traversed, simply check the Walkable property.
You can get the closest node to a point using the GetNearest method.

 var node = AstarPath.active.GetNearest (somePosition, NNConstraint.None).node;
 if (node.Walkable) {
      // Do something
 }
1 Like

Thank you! What variable type is ‘node’? I tried making a public Node node but that doesn’t seem to be right

Hi

It has the type GraphNode.
See http://arongranberg.com/astar/docs/class_astar_path.php#aae44d9d57ed269658eef4dddae3af43e

1 Like

Thanks a lot for your help, Aron. Both with this and the other question. My budding turn based combat system is really coming along now.