the navigation mesh to use for the query
Optional
params: NavMeshQueryParamsoptional additional parameters
const query = new NavMeshQuery(navMesh);
const query = new NavMeshQuery(navMesh, { maxNodes: 2048 });
Constructs a navigation mesh query object from a raw object.
Default query filter.
Default search distance along each axis.
Returns the closest point on the given polygon to the given position.
The reference of the polygon
The position to find the closest point to
Finds a straight path from the start position to the end position.
the start position
the end position
Optional
options: { additional options
Optional
filter?: QueryFilterThe polygon filter to apply to the query.
this.defaultFilter
Optional
halfThe search distance along each axis. [(x, y, z)]
this.defaultQueryHalfExtents
Optional
maxThe maximum number of polygons the path array can hold. [Limit: >= 1]
256
Optional
maxThe maximum number of points the straight path arrays can hold. [Limit: > 0]
256
an array of Vector3 positions that make up the path, or an empty array if no path was found.
Optional
error?: { Error information if the path computation failed.
Description of the error.
Optional
status?: numberA dtStatus status code if relevant.
The result path.
Whether a path was successfully computed.
Finds the closest point on the NavMesh to the given position.
the position to find the closest point to
Optional
options: { additional options
Optional
filter?: QueryFilterThe polygon filter to apply to the query.
this.defaultFilter
Optional
halfThe search distance along each axis. [(x, y, z)]
this.defaultQueryHalfExtents
the result of the find closest point operation
Finds the polygon nearest to the given position.
Optional
options: { Optional
filter?: QueryFilterThe polygon filter to apply to the query.
this.defaultFilter
Optional
halfThe search distance along each axis. [(x, y, z)]
this.defaultQueryHalfExtents
Finds a path from the start polygon to the end polygon.
the reference id of the start polygon.
the reference id of the end polygon.
position within the start polygon.
position within the end polygon.
Optional
options: { additional options
Optional
filter?: QueryFilterThe polygon filter to apply to the query.
this.defaultFilter
Optional
maxThe maximum number of polygons the path array can hold. [Limit: >= 1]
256
The polys
array returned must be freed after use.
findPathResult.polys.destroy();
Finds the polygons along the navigation graph that touch the specified circle.
Reference of polygon to start search from
Center of circle
Radius of circle
Optional
options: { Optional
filter?: QueryFilterThe polygon filter to apply to the query.
this.defaultFilter
Optional
maxThe maximum number of polygons the result arrays can hold.
256
Returns a random point on the navmesh.
Optional
options: { additional options
Optional
filter?: QueryFilterThe polygon filter to apply to the query.
this.defaultFilter
a random point on the navmesh
Returns a random point on the NavMesh within the given radius of the given position.
the center of the search circle
the radius of the search circle
Optional
options: { additional options
Optional
filter?: QueryFilterThe polygon filter to apply to the query.
this.defaultFilter
Optional
halfThe search distance along each axis. [(x, y, z)]
this.defaultQueryHalfExtents
Optional
startThe reference id of the polygon to start the search from. If not provided, the nearest polygon to the position will be used.
Finds the straight path from the start to the end position within the polygon corridor.
This method peforms what is often called 'string pulling'.
The start position is clamped to the first polygon in the path, and the end position is clamped to the last. So the start and end positions should normally be within or very near the first and last polygons respectively.
The returned polygon references represent the reference id of the polygon that is entered at the associated path position. The reference id associated with the end point will always be zero. This allows, for example, matching off-mesh link points to their representative polygons.
If the provided result arrays are too small for the entire result set, they will be filled as far as possible from the start toward the end position.
path start position
path end position
an array of polygon references that represent the path corridor
Optional
options: { additional options
Optional
maxThe maximum number of points the straight path arrays can hold. [Limit: > 0]
256
Optional
straightOptions for dtNavMeshQuery::findStraightPath
Add a vertex at every polygon edge crossing where area changes. DT_STRAIGHTPATH_AREA_CROSSINGS = 1
Add a vertex at every polygon edge crossing. DT_STRAIGHTPATH_ALL_CROSSINGS = 2
0
the straight path result
The straightPath, straightPathFlags, and straightPathRefs arrays returned must be freed after use.
findStraightPathResult.straightPath.destroy();
findStraightPathResult.straightPathFlags.destroy();
findStraightPathResult.straightPathRefs.destroy();
The straight path points.
The number of points in the straight path.
The straight path flags.
The reference ids of the visited polygons.
Detour.DT_STRAIGHTPATH_START Detour.DT_STRAIGHTPATH_END Detour.DT_STRAIGHTPATH_OFFMESH_CONNECTION
Gets the height of the polygon at the provided position using the height detail.
the reference id of the polygon.
a position within the xz-bounds of the polygon.
Moves from the start to the end position constrained to the navigation mesh.
the reference id of the start polygon.
a position of the mover within the start polygon.
the desired end position of the mover.
Optional
options: { Optional
filter?: QueryFilterThe polygon filter to apply to the query.
this.defaultFilter
Optional
maxThe maximum number of polygons the output visited array can hold.
256
The result of the move along surface operation.
Finds polygons that overlap the search box.
The center of the search box
The search distance along each axis
Optional
options: { Optional
filter?: QueryFilterThe polygon filter to apply to the query.
this.defaultFilter
Optional
maxThe maximum number of polygons the search result can hold.
256
Casts a 'walkability' ray along the surface of the navigation mesh from the start position toward the end position.
This method is meant to be used for quick, short distance checks.
If the path array is too small to hold the result, it will be filled as far as possible from the start postion toward the end position.
The raycast ignores the y-value of the end position. (2D check.) This places significant limits on how it can be used.
Using the Hit Parameter (t)
If the hit parameter is a very high value, then the ray has hit the end position. In this case the path represents a valid corridor to the end position and the value of hitNormal is undefined.
If the hit parameter is zero, then the start position is on the wall that was hit and the value of hitNormal is undefined.
If 0 < t < 1.0 then the following applies:
distanceToHitBorder = distanceToEndPosition * t
hitPoint = startPos + (endPos - startPos) * t
Use Case Restriction
Consider a scene where there is a main floor with a second floor balcony that hangs over the main floor. So the first floor mesh extends below the balcony mesh. The start position is somewhere on the first floor. The end position is on the balcony.
The raycast will search toward the end position along the first floor mesh. If it reaches the end position's xz-coordinates it will indicate FLT_MAX,(no wall hit), meaning it reached the end position. This is one example of why this method is meant for short distance checks.
the reference id of the start polygon.
a position within the start polygon representing the start of the ray
the position to cast the ray toward.
Optional
options: { additional options
Optional
filter?: QueryFilterThe polygon filter to apply to the query.
this.defaultFilter
Optional
prevOptional parent of start ref. Used during for cost calculation.
Optional
raycastDetermines how the raycast behaves.
// Raycast should calculate movement cost along the ray and fill RaycastHit::cost DT_RAYCAST_USE_COSTS = 1
0
The index of the edge on the final polygon where the wall was hit.
The normal of the nearest wall hit.
The maximum number of polygons the path can contain.
The reference ids of the visited polygons.
The cost of the path until hit.
The status of the raycast.
Whether the raycast was successful.
The hit parameter.
Constructs a new navigation mesh query object.