A* Pathfinding Project
3.1.4
The A* Pathfinding Project for Unity 3D
|
Example AI. More...
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 |
NavmeshController | navmeshController |
NavmeshController which handles movement if not null. | |
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. | |
Example AI.
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".
|
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 |
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.
void Reset | ( | ) |
Will make the AI give up it's current path and stop completely.
void Resume | ( | ) |
void Stop | ( | ) |
IEnumerator WaitToRepath | ( | ) |
Waits the remaining time until the AI should issue a new path request.
The remaining time is defined by Time.time - lastPathSearch
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.
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]