A* Pathfinding Project  3.1.4
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Enumerations Properties Groups Pages
NavmeshController Class Reference

CharacterController helper for use on navmeshes. More...

+ Inheritance diagram for NavmeshController:
+ Collaboration diagram for NavmeshController:

Public Member Functions

Node ClampAlongNavmesh (Vector3 startPos, Node startNode, Vector3 endPos, out Vector3 clampedPos)
 Applies constrained movement from startPos to endPos.
 
Vector3 ClampMove (Vector3 currentPosition, Vector3 direction)
 Clamps a movement vector to the navmesh.
 
Vector3 ClampToNavmesh (Vector3 target)
 
Vector3 SimpleMove (Vector3 currentPosition, Vector3 direction)
 Performs a Simple Move.
 
void Start ()
 Small closed list used for the tiny breadth-first-search.
 
void Teleport ()
 Call when a move out of the navmesh has been made.
 

Public Attributes

float forwardPlanning
 Factor applied to direction during SimpleMove.
 

Protected Attributes

CharacterController controller
 
Node prevNode
 
Vector3 prevPos
 

Private Member Functions

void OnAstarAwake ()
 
void OnDisable ()
 
void OnRescan (AstarPath active)
 Called on graph rescanning, updates the current node.
 

Private Attributes

List< NodetmpClosed = new List<Node>(32)
 Small stack used for the tiny breadth-first-search.
 
Stack< NodetmpStack = new Stack<Node>(16)
 

Detailed Description

CharacterController helper for use on navmeshes.

This character controller helper will clamp the desired movement to the navmesh before moving.
This results in that this character will not move out from the navmesh by it's own force by more than very small distances.
It can be used as a regular CharacterController, but the only move command you can use currently is SimpleMove.

Note
A CharacterController component needs to be attached to the same GameObject for this script to work
It does only work on Navmesh based graphs (NavMeshGraph, RecastGraph)
It does not work very well with links in the graphs

Member Function Documentation

Node ClampAlongNavmesh ( Vector3  startPos,
Node  startNode,
Vector3  endPos,
out Vector3  clampedPos 
)

Applies constrained movement from startPos to endPos.

The result is stored in clampedPos. Returns the new current node

+ Here is the call graph for this function:

Vector3 ClampMove ( Vector3  currentPosition,
Vector3  direction 
)

Clamps a movement vector to the navmesh.

Returns
The clamped movement direction

+ Here is the caller graph for this function:

Vector3 SimpleMove ( Vector3  currentPosition,
Vector3  direction 
)

Performs a Simple Move.

Similar to CharacterController.SimpleMove, but this function will clamp the desired movement to the navmesh Requires a CharacterController to be attached to the GameObject.

Returns
The clamped movement direction
See Also
ClampMove

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Teleport ( )

Call when a move out of the navmesh has been made.

For example if you have teleported your unit to a new location you need to call this function to update the current node.

transform.position = new Vector3 (50,5,50);
GetComponent<NavmeshController>().Teleport ();

+ Here is the caller graph for this function:

Member Data Documentation

float forwardPlanning

Factor applied to direction during SimpleMove.

A small value decreases corner cutting, a high value makes it take edges further away into account


The documentation for this class was generated from the following file: