[This is preliminary documentation and is subject to change.]

Casts a 'walkability' ray along the surface of the navigation mesh from the start point toward the end point.

Namespace: org.critterai.nav
Assembly: cai-nav (in cai-nav.dll) Version: (


 C#  Visual Basic  Visual C++ 
public NavStatus Raycast(
	NavmeshPoint start,
	Vector3 end,
	NavmeshQueryFilter filter,
	out float hitParameter,
	out Vector3 hitNormal,
	uint[] path,
	out int pathCount
Public Function Raycast ( _
	start As NavmeshPoint, _
	end As Vector3, _
	filter As NavmeshQueryFilter, _
	<OutAttribute> ByRef hitParameter As Single, _
	<OutAttribute> ByRef hitNormal As Vector3, _
	path As UInteger(), _
	<OutAttribute> ByRef pathCount As Integer _
) As NavStatus
NavStatus Raycast(
	NavmeshPoint start, 
	Vector3 end, 
	NavmeshQueryFilter^ filter, 
	[OutAttribute] float% hitParameter, 
	[OutAttribute] Vector3% hitNormal, 
	array<unsigned int>^ path, 
	[OutAttribute] int% pathCount


A point within the start polygon representing the start of the ray.
The point to cast the ray toward.
The filter to apply to the query.
The hit parameter. (>1E38 if no hit.)
The normal of the nearest wall hit.
The references of the visited polygons. [(polyRef) * pathCount] (Optional)
The number of visited polygons.

Return Value

The NavStatus flags for the query.


This method is meant to be used for quick short distance checks.

If the path buffer is too small to hold the result, it will be filled as far as possible from the start point toward the end point.

Using the Hit Paramter

If the hit parameter is a very high value (>1E38), then the ray has hit the end point. In this case the path represents a valid corridor to the end point and the value of hitNormal is undefined.

If the hit parameter is zero, then the start point is on the border that was hit and the value of hitNormal is undefined.

If 0 < hitParameter < 1.0 then the following applies:

distanceToHitBorder = distanceToEndPoint * hitParameter
hitPoint = startPoint + (endPoint - startPoint) * hitParameter

Use Case Restriction

The raycast ignores the y-value of the end point. (2D check) This places significant limits on how it can be used. Example scenario:

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 point is somewhere on the first floor. The end point is on the balcony.

The raycast will search toward the end point along the first floor mesh. If it reaches the end point's xz-coordinates it will indicate 'no hit', meaning it reached the end point.

See Also