@aron_granberg
AstarPath.active.GetNearest(point1, NNConstraint.Default).node;
this function always returns a node, is there a function that the point is not on the navmesh, it will return null.
@aron_granberg
AstarPath.active.GetNearest(point1, NNConstraint.Default).node;
this function always returns a node, is there a function that the point is not on the navmesh, it will return null.
Hi
This depends on what graph type you are using and what you mean by “on the navmesh”.
If you are using a grid graph, the easiest is to do
bool isOnNavmesh = AstarPath.active.GetNearest(point, NNConstraint.None).node.Walkable;
Which gets the closest node and checks if it is walkable.
If you are using a recast/navmesh graph you can use the PointOnNavmesh method.
var node = AstarPath.active.data.recastGraph.PointOnNavmesh(point, NNConstraint.Default);
if (node != null) Debug.Log("On the navmesh when seen from above");