Class FloodPath Extends Path
Calculates paths from everywhere 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, it floods the graph. This data will remain stored in the path. Then you can calculate a FloodPathTracer path. That path will trace the path from its starting point all the way to where this path started. A FloodPathTracer search is extremely fast to calculate compared to a normal path request.
It is very useful in for example 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.
Usage:
At start, you calculate ONE FloodPath and save the reference (it will be needed later).
Then when a unit is spawned or needs its path recalculated, start a FloodPathTracer path from the unit's position. It will then find the shortest path to the point specified when you calculated the FloodPath extremely quickly.
If you update the graph (for example place a tower in a TD game) or need to change the target point, you calculate a new FloodPath and make all AIs calculate new FloodPathTracer paths.
Since a FloodPathTracer path only uses precalculated information, it will always use the same penalties/tags as the FloodPath it references. If you want to use different penalties/tags, you will have to calculate a new FloodPath.
Here follows some example code of the above list of steps: public static FloodPath fpath;
public void Start () {
fpath = FloodPath.Construct (someTargetPosition, null);
AstarPath.StartPath (fpath);
}
When searching for a new path to someTargetPosition from let's say transform.position, you do FloodPathTracer fpathTrace = FloodPathTracer.Construct (transform.position,fpath,null);
Where OnPathComplete is your callback function.
seeker.StartPath (fpathTrace,OnPathComplete);
Another thing to note is that if you are using an NNConstraint on the FloodPathTracer, they must always inherit from FloodPathConstraint.
The easiest is to just modify the instance of FloodPathConstraint which is created as the default one.
Integration with the built-in movement scripts
The built-in movement scripts cannot calculate a FloodPathTracer path themselves, but you can use the SetPath method to assign such a path to them: var ai = GetComponent<IAstarAI>();
// Disable the agent's own path recalculation code
ai.canSearch = false;
ai.SetPath(FloodPathTracer.Construct(ai.position, floodPath));
This is an A* Pathfinding Project Pro feature only. This function/class/variable might not exist in the Free version of the A* Pathfinding Project or the functionality might be limited.
The Pro version can be bought here
Public Methods
Public Static Methods
Public Variables
If false, will not save any information.
Public Static Variables
Inherited Public Members
Current state of the path.
Opens a connection between two nodes during the A* search.
Burst-compiled internal implementation of OpenCandidateConnection.
Open a connection to the temporary end node if necessary.
Returns the state of the path in the pathfinding pipeline.
Paths use this to skip adding nodes to the search heap.
Callback to call when the path is complete.
How long it took to calculate this path in milliseconds.
Which graph tags are traversable.
If the path failed, this is true.
Additional info on why a path failed.
Determines which heuristic to use.
Scale of the heuristic values.
Immediate callback to call when the path is complete.
Constraint for how to search for nodes.
ID of this path.
Number of nodes this path has searched.
Penalties for each tag.
Provides additional traversal information to a path request.
Holds the (possibly post-processed) path as a Vector3 list.
Private/Protected Members
Calculates the path until completed or until the time has passed targetTick.
Writes text shared for all overrides of DebugString to the string builder.
Writes text shared for all overrides of DebugString to the string builder.
Called when a valid node has been found for the end of the path.
List of zeroes to use as default tag penalties.
Target to use for H score calculation.
True if the Reset function has been called.
Target to use for H score calculations.
The tag penalties that are actually used.
Data for the thread calculating this path.