I am trying to determine if an AIPath (“Pathfinding/AI/AIPath (2D,3D)”) is on a navmesh or not.
Previously (in Unity’s included NavMeshAgent) I would check the “isOnNavMesh” property but I cannot seem to find a replacement in A* Pathfinding Project.
I am using the Pro version. Does anyone know how to check if there is NavMesh for a Seeker?
Hi
“is on a navmesh” is a bit loosely defined. There are several possible definitions for it.
One way is to check if the closest point on the navmesh is walkable (only reasonable for grid graphs)
if (AstarPath.active.GetNearest(transform.position).node.Walkable) {
// On navmesh
}
Another way is to check if the closest point on the navmesh is closer than some threshold.
var dirTonavmesh = transform.position - closest.position;
// Ignore y distance
dirTonavmesh.y = 0;
if (dirToNavmesh.magnitude < 0.1) {
// On navmesh
}