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

Attempts to optimize the path if the specified point is visible from the current position.

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


 C#  Visual Basic  Visual C++ 
public void OptimizePathVisibility(
	Vector3 next,
	float optimizationRange,
	bool updateCorners
Public Sub OptimizePathVisibility ( _
	next As Vector3, _
	optimizationRange As Single, _
	updateCorners As Boolean _
void OptimizePathVisibility(
	Vector3 next, 
	float optimizationRange, 
	bool updateCorners


The point to search toward.
The maximum range to search. [Limit: > 0]
True if the corners data should be refreshed.


Improves pathfinding appearance when using meshes that contain non-border. vertices. (E.g. Tiled meshes and meshes constructed using multiple areas.)

The only time updateCorners should be set to false is if a move or other optimization method is to be called next. Otherwise the corner data may become invalid.

Inaccurate locomotion or dynamic obstacle avoidance can force the agent position significantly outside the original corridor. Over time this can result in the formation of a non-optimal corridor. A non-optimal corridor can also form near non-border vertices. (I.e. At tile corners or area transitions.)

This function uses an efficient local visibility search to try to optimize the corridor between the current position and next.

The corridor will change only if next is visible from the current position and moving directly toward the point is better than following the existing path.

The more inaccurate the client movement, the more beneficial this method becomes. Simply adjust the frequency of the call to match the needs to the client.

This method is not suitable for long distance searches.

See Also