Function NavmeshBase.PointOnNavmesh

PointOnNavmesh (Vector3 position, NNConstraint constraint)

Finds the first node which contains position.

Public
GraphNode PointOnNavmesh (

Vector3

position

NNConstraint

constraint

)

Finds the first node which contains position.

"Contains" is defined as position is inside the triangle node when seen from above. In case of a multilayered environment, the closest node which contains the point is returned.

Returns null if there was no node containing the point. This serves as a quick check for "is this point on the navmesh or not".

Note that the behaviour of this method is distinct from the GetNearest method. The GetNearest method will return the closest node to a point, which is not necessarily the one which contains it when seen from above.

Uses NNConstraint.distanceMetric to define the "up" direction. The up direction of the graph will be used if it is not set. The up direction defines what "inside" a node means. A point is inside a node if it is inside the triangle when seen from above.

See

GetNearest

IsPointOnNavmesh, if you only need to know if the point is on the navmesh or not.