|
A* Pathfinding Project
3.0.9
The A* Pathfinding Project for Unity
|
Example AI. More...
Collaboration diagram for AIFollow:| 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. |
| 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. |
| 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. |
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".
| 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.
| void Resume | ( | ) |
| void Start | ( | ) |
Use this for initialization.
| void Stop | ( | ) |
| 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
| 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.
CharacterController controller [protected] |
CharacterController which handles movement.
NavmeshController navmeshController [protected] |
NavmeshController which handles movement if not null.
Vector3 [] path [protected] |
This is the path the AI is currently following.
| 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).
This value is multiplied with pickNextWaypointDistance before it is used. Recommended range [0...1]
Transform tr [protected] |
Transform, cached because of performance.