bool
IsPointOnNavmesh
(
Vector3 | position | The point to check |
)
True if the point is on a walkable part of the navmesh, as seen from above.
A point is considered on the navmesh if it is above or below a walkable navmesh surface, at any distance, and if it is not above/below a closer unwalkable node.
NoteThis means that, for example, in multi-story building a point will be considered on the navmesh if any walkable floor is below or above the point. If you want more complex behavior then you can use the GetNearest method together with the appropriate NNConstraint.distanceMetric settings for your use case.
This uses the graph's natural up direction to determine which way is up. Therefore, it will also work on rotated graphs, as well as graphs in 2D mode.
This method works for all graph types. However, for PointGraphs, this will never return true unless you pass in the exact coordinate of a node, since point nodes do not have a surface.
NoteFor spherical navmeshes (or other weird shapes), this method will not work as expected, as there's no well defined "up" direction.