A* Pathfinding Project  3.8
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
AIFollow Class Reference

Example AI. More...

Detailed Description

Example AI.

Deprecated:
This script has been deprecated, use AIPath, RichAI or MineBotAI instead

Public Member Functions

void OnDrawGizmos ()
 Draws helper gizmos.
 
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 ()
 Called when the AI reached the end of path.
 
virtual void Repath ()
 Recalculates the path to target.
 
void Reset ()
 Will make the AI give up it's current path and stop completely.
 
void Resume ()
 Resumes walking and path searching the AI.
 
void Start ()
 Use this for initialization.
 
void Stop ()
 Stops the AI.
 
void Update ()
 Update is called once per frame.
 
IEnumerator WaitToRepath ()
 Waits the remaining time until the AI should issue a new path request.
 

Public Attributes

bool canMove = true
 Can it move.
 
bool canSearch = true
 Should paths be searched for.
 
bool drawGizmos = false
 
float pickNextWaypointDistance = 1F
 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.
 
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).
 

Protected Attributes

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

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 Reset ( )

Will make the AI give up it's current path and stop completely.

void Resume ( )

Resumes walking and path searching the AI.

Since
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

Since
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.

bool drawGizmos = false
float lastPathSearch = -9999
protected
Vector3 [] path
protected

This is the path the AI is currently following.

int pathIndex = 0
protected
float pickNextWaypointDistance = 1F

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: