A* Pathfinding Project  3.0.9
The A* Pathfinding Project for Unity
AIFollow Class Reference

Example AI. More...

+ Collaboration diagram for AIFollow:

List of all members.

Public Member Functions

void Start ()  Use this for initialization.
void OnPathComplete (Path p)  Called when a path has completed it's calculation.
IEnumerator WaitToRepath ()  Waits the remaining time until the AI should issue a new path request.
void Stop ()  Stops the AI.
void Resume ()  Resumes walking and path searching the AI.
virtual void Repath ()  Recalculates the path to target.
void PathToTarget (Vector3 targetPoint)  Start a new path moving to targetPoint.
virtual void ReachedEndOfPath ()  Called when the AI reached the end of path.
void Update ()  Update is called once per frame.
void OnDrawGizmos ()  Draws helper gizmos.

Public Variables

Transform target  Target to move to.
float repathRate = 0.1F  How often to search for a new path.
float pickNextWaypointDistance = 1F  The minimum distance to a waypoint to consider it as "reached".
float targetReached = 0.2F  The minimum distance to the end point of a path to consider it "reached" (multiplied with pickNextWaypointDistance).
float speed = 5  Units per second.
float rotationSpeed = 1  How fast the AI can turn around.
bool drawGizmos = false  
bool canSearch = true  Should paths be searched for.
bool canMove = true  Can it move.

Protected Variables

Seeker seeker  Seeker component which handles pathfinding calls.
CharacterController controller  CharacterController which handles movement.
NavmeshController navmeshController  NavmeshController which handles movement if not null.
Transform tr  Transform, cached because of performance.
float lastPathSearch = -9999  
int pathIndex = 0  
Vector3[] path  This is the path the AI is currently following.

Detailed Description

Example AI.


Member Function Documentation

void OnDrawGizmos ( )

Draws helper gizmos.

Currently draws a circle around the current target point with the size showing how close the AI need to get to it for it to count as "reached".

void OnPathComplete ( Path  p)

Called when a path has completed it's calculation.

void PathToTarget ( Vector3  targetPoint)

Start a new path moving to targetPoint.

virtual void ReachedEndOfPath ( ) [virtual]

Called when the AI reached the end of path.

This will be called once for every path it completes, so if you have a really fast repath rate it will call this function often if when it stands on the end point.

virtual void Repath ( ) [virtual]

Recalculates the path to target.

Queries a path request to the Seeker, the path will not be calculated instantly, but will be put on a queue and calculated as fast as possible. It will wait if the current path request by this seeker has not been completed yet.

See also:
Seeker::IsDone
void Resume ( )

Resumes walking and path searching the AI.

Version:
Added in 3.0.8
See also:
Stop
canMove
canSearch
void Start ( )

Use this for initialization.

void Stop ( )

Stops the AI.

Also stops new search queries from being made

Version:
Before 3.0.8 This does not prevent new path calls from making the AI move again
See also:
Resume
canMove
canSearch
void Update ( )

Update is called once per frame.

IEnumerator WaitToRepath ( )

Waits the remaining time until the AI should issue a new path request.

The remaining time is defined by Time.time - lastPathSearch


Member Data Documentation

bool canMove = true

Can it move.

Enables or disables movement and rotation

bool canSearch = true

Should paths be searched for.

Setting this to false will make the AI not search for paths anymore, can save some CPU cycles. It will check every repathRate seconds if it should start to search for paths again.

Note:
It will not cancel paths which are currently being calculated
CharacterController controller [protected]

CharacterController which handles movement.

NavmeshController which handles movement if not null.

Vector3 [] path [protected]

This is the path the AI is currently following.

The minimum distance to a waypoint to consider it as "reached".

float repathRate = 0.1F

How often to search for a new path.

float rotationSpeed = 1

How fast the AI can turn around.

Seeker seeker [protected]

Seeker component which handles pathfinding calls.

float speed = 5

Units per second.

Transform target

Target to move to.

float targetReached = 0.2F

The minimum distance to the end point of a path to consider it "reached" (multiplied with pickNextWaypointDistance).

This value is multiplied with pickNextWaypointDistance before it is used. Recommended range [0...1]

Transform tr [protected]

Transform, cached because of performance.


The documentation for this class was generated from the following file:
 All Classes Functions Variables Enumerations Properties