|
A* Pathfinding Project
3.0.9
The A* Pathfinding Project for Unity
|
Floods the area completely for easy computation of any path to a single point. More...
Inheritance diagram for FloodPath:
Collaboration diagram for FloodPath:| FloodPath (Vector3 start, OnPathDelegate callbackDelegate) | Creates a new FloodPath instance. | ||
| override float | CalculateStep (float remainingFrameTime) | Opens nodes until there are none left to search (or until the max time limit has been exceeded) |
Floods the area completely for easy computation of any path to a single point.
This path is a bit special, because it does not do anything useful by itself. What it does is that it calculates paths to all nodes it can reach, floods it. This data will remain stored in the graph. Then you can call a FloodPathTracer path, that path will trace the path from it's starting point all the way to where this path started flooding and thus generating a path extreamly quicly.
It is very useful in for example TD (Tower Defence) games where all your AIs will walk to the same point, but from different places, and you do not update the graph or change the target point very often, what changes is their positions and new AIs spawn all the time (which makes it hard to use the MultiTargetPath).
With this path type, it can all be handled easily.
Here follows some example code of the above list of steps:
public static FloodPath fpath; public void Start () { fpath = new FloodPath (someTargetPosition, null); AstarPath.StartPath (fpath); }
When searching for a new path to someTargetPosition from let's say transform.position, you do
FloodPathTracer fpathTrace = new FloodPathTracer (transform.position,fpath,null); seeker.StartPath (fpathTrace,OnPathComplete);
Where OnPathComplete is your callback function.
public void Start () { AstarPath.On65KOverflow += MyCallbackFunction; } public void MyCallbackFunction () { //The callback is nulled every time it is called, so we need to register again AstarPath.On65KOverflow += MyCallbackFunction; //Recalculate the path }
| override float CalculateStep | ( | float | remainingFrameTime | ) | [virtual] |
Opens nodes until there are none left to search (or until the max time limit has been exceeded)
Reimplemented from Path.