A* Pathfinding Project  3.1.4
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Enumerations Properties Groups Pages
Seeker Class Reference

Handles path calls for a single unit. More...

+ Inheritance diagram for Seeker:
+ Collaboration diagram for Seeker:

Public Types

enum  ModifierPass { PreProcess, PostProcessOriginal, PostProcess }
 

Public Member Functions

void Awake ()
 
IEnumerator DelayPathStart (Path p)
 
void DeregisterModifier (IPathModifier mod)
 
Path GetCurrentPath ()
 Returns path.
 
Path GetNewPath (Vector3 start, Vector3 end)
 Returns a new path instance.
 
bool IsDone ()
 Is the current path done calculating.
 
void OnDestroy ()
 
void OnDrawGizmos ()
 
void OnMultiPathComplete (Path p)
 Called once for a MultiTargetPath.
 
void OnPartialPathComplete (Path p)
 Called for each path in a MultiTargetPath.
 
void OnPathComplete (Path p)
 Called when a path has completed.
 
void OnPathComplete (Path p, bool runModifiers, bool sendCallbacks)
 Called when a path has completed.
 
void PostProcess (Path p)
 Post Processes the path.
 
void RegisterModifier (IPathModifier mod)
 
void RunModifiers (ModifierPass pass, Path p)
 Runs modifiers on path p.
 
string StackTrace ()
 
MultiTargetPath StartMultiTargetPath (Vector3 start, Vector3[] endPoints, bool pathsForAll, OnPathDelegate callback=null, int graphMask=-1)
 Starts a Multi Target Path from one start point to multiple end points.
 
MultiTargetPath StartMultiTargetPath (Vector3[] startPoints, Vector3 end, bool pathsForAll, OnPathDelegate callback=null, int graphMask=-1)
 Starts a Multi Target Path from multiple start points to a single target point.
 
MultiTargetPath StartMultiTargetPath (MultiTargetPath p, OnPathDelegate callback=null, int graphMask=-1)
 Starts a Multi Target Path.
 
Path StartPath (Vector3 start, Vector3 end)
 Call this function to start calculating a path.
 
Path StartPath (Vector3 start, Vector3 end, OnPathDelegate callback)
 Call this function to start calculating a path.
 
Path StartPath (Vector3 start, Vector3 end, OnPathDelegate callback, int graphMask)
 Call this function to start calculating a path.
 
Path StartPath (Path p, OnPathDelegate callback=null, int graphMask=-1)
 Call this function to start calculating a path.
 

Public Attributes

bool detailedGizmos = false
 
bool drawGizmos = true
 
List< NodelastCompletedNodePath
 
List< Vector3 > lastCompletedVectorPath
 
OnPathDelegate pathCallback
 Callback for when a path is completed.
 
OnPathDelegate postProcessOriginalPath
 For anything which requires the original nodes (Node[]) (before modifiers) to work.
 
OnPathDelegate postProcessPath
 Anything which only modifies the positions (Vector3[])
 
OnPathDelegate preProcessPath
 Called before pathfinding is started.
 
bool saveGetNearestHints = true
 Saves nearest nodes for previous path to enable faster Get Nearest Node calls.
 
StartEndModifier startEndModifier = new StartEndModifier ()
 
int[] tagPenalties = new int[32]
 Penalties for each tag.
 
TagMask traversableTags = new TagMask (-1,-1)
 

Protected Attributes

uint lastPathID = 0
 The path ID of the last path queried.
 
Path path
 The current path.
 
Path prevPath
 

Private Attributes

Node endHint
 
List< IPathModifiermodifiers = new List<IPathModifier> ()
 
OnPathDelegate onPartialPathDelegate
 
OnPathDelegate onPathDelegate
 
Node startHint
 
OnPathDelegate tmpPathCallback
 Temporary callback only called for the current path.
 

Detailed Description

Handles path calls for a single unit.

This is a component which is meant to be attached to a single unit (AI, Robot, Player, whatever) to handle it's pathfinding calls. It also handles post-processing of paths using modifiers.

See Also
Pathfinding interface
Examples:
AstarAI.cs, EndingCondition.cs, and MultiTargetPathExample.cs.

Member Function Documentation

Path GetNewPath ( Vector3  start,
Vector3  end 
)

Returns a new path instance.

The path will be taken from the path pool if path recycling is turned on.
This path can be sent to StartPath(Path,OnPathDelegate,int) with no change, but if no change is required StartPath(Vector3,Vector3,OnPathDelegate) does just that.

Seeker seeker = GetComponent (typeof(Seeker)) as Seeker;
Path p = seeker.GetNewPath (transform.position, transform.position+transform.forward*100);
p.nnConstraint = NNConstraint.Default;

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool IsDone ( )

Is the current path done calculating.

Returns true if the current path has been returned or if the path is null.

Note
Do not confuse this with Pathfinding.Path.IsDone. They do mostly return the same value, but not always.
Since
Added in 3.0.8
Version
Behaviour changed in 3.2

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void OnMultiPathComplete ( Path  p)

Called once for a MultiTargetPath.

Only returns the path, does not post process.

A* Pro Feature:
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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void OnPartialPathComplete ( Path  p)

Called for each path in a MultiTargetPath.

Only post processes the path, does not return it.

A* Pro Feature:
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

+ Here is the call graph for this function:

void OnPathComplete ( Path  p)

Called when a path has completed.

This should have been implemented as optional parameter values, but that didn't seem to work very well with delegates (the values weren't the default ones)

See Also
OnPathComplete(Path,bool,bool)

+ Here is the caller graph for this function:

void OnPathComplete ( Path  p,
bool  runModifiers,
bool  sendCallbacks 
)

Called when a path has completed.

Will post process it and return it by calling tmpPathCallback and pathCallback

+ Here is the call graph for this function:

void PostProcess ( Path  p)

Post Processes the path.

This will run any modifiers attached to this GameObject on the path. This is identical to calling RunModifiers(ModifierPass.PostProcess, path)

See Also
RunModifiers
Since
Added in 3.2

+ Here is the call graph for this function:

MultiTargetPath StartMultiTargetPath ( Vector3  start,
Vector3[]  endPoints,
bool  pathsForAll,
OnPathDelegate  callback = null,
int  graphMask = -1 
)

Starts a Multi Target Path from one start point to multiple end points.

A Multi Target Path will search for all the end points in one search and will return all paths if pathsForAll is true, or only the shortest one if pathsForAll is false.

Parameters
startThe start point of the path
endPointsThe end points of the path
pathsForAllIndicates whether or not a path to all end points should be searched for or only to the closest one
callbackThe function to call when the path has been calculated
graphMaskMask used to specify which graphs should be searched for close nodes. See Pathfinding::NNConstraint::graphMask.
A* Pro Feature:
This parameter does not exist or has limited functionality in the Free version of the A* Pathfinding Project

callback and pathCallback will be called when the path has completed. Callback will not be called if the path is canceled (e.g when a new path is requested before the previous one has completed)

A* Pro Feature:
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
See Also
Pathfinding::MultiTargetPath
Example of how to use multi-target-paths

+ Here is the caller graph for this function:

MultiTargetPath StartMultiTargetPath ( Vector3[]  startPoints,
Vector3  end,
bool  pathsForAll,
OnPathDelegate  callback = null,
int  graphMask = -1 
)

Starts a Multi Target Path from multiple start points to a single target point.

A Multi Target Path will search from all start points to the target point in one search and will return all paths if pathsForAll is true, or only the shortest one if pathsForAll is false.

Parameters
startPointsThe start points of the path
endThe end point of the path
pathsForAllIndicates whether or not a path from all start points should be searched for or only to the closest one
callbackThe function to call when the path has been calculated
graphMaskMask used to specify which graphs should be searched for close nodes. See Pathfinding::NNConstraint::graphMask.
A* Pro Feature:
This parameter does not exist or has limited functionality in the Free version of the A* Pathfinding Project

callback and pathCallback will be called when the path has completed. Callback will not be called if the path is canceled (e.g when a new path is requested before the previous one has completed)

A* Pro Feature:
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
See Also
Pathfinding::MultiTargetPath
Example of how to use multi-target-paths

+ Here is the call graph for this function:

MultiTargetPath StartMultiTargetPath ( MultiTargetPath  p,
OnPathDelegate  callback = null,
int  graphMask = -1 
)

Starts a Multi Target Path.

Takes a MultiTargetPath and wires everything up for it to send callbacks to the seeker for post-processing.

Parameters
pThe path to start calculating
callbackThe function to call when the path has been calculated
graphMaskMask used to specify which graphs should be searched for close nodes. See Pathfinding::NNConstraint::graphMask.
A* Pro Feature:
This parameter does not exist or has limited functionality in the Free version of the A* Pathfinding Project

callback and pathCallback will be called when the path has completed. Callback will not be called if the path is canceled (e.g when a new path is requested before the previous one has completed)

A* Pro Feature:
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
See Also
Pathfinding::MultiTargetPath
Example of how to use multi-target-paths

+ Here is the call graph for this function:

Path StartPath ( Vector3  start,
Vector3  end 
)

Call this function to start calculating a path.

Parameters
startThe start point of the path
endThe end point of the path
Examples:
AstarAI.cs, and EndingCondition.cs.

+ Here is the caller graph for this function:

Path StartPath ( Vector3  start,
Vector3  end,
OnPathDelegate  callback 
)

Call this function to start calculating a path.

Parameters
startThe start point of the path
endThe end point of the path
callbackThe function to call when the path has been calculated

callback will be called when the path has completed. Callback will not be called if the path is canceled (e.g when a new path is requested before the previous one has completed)

+ Here is the call graph for this function:

Path StartPath ( Vector3  start,
Vector3  end,
OnPathDelegate  callback,
int  graphMask 
)

Call this function to start calculating a path.

Parameters
startThe start point of the path
endThe end point of the path
callbackThe function to call when the path has been calculated
graphMaskMask used to specify which graphs should be searched for close nodes. See Pathfinding::NNConstraint::graphMask.
A* Pro Feature:
This parameter does not exist or has limited functionality in the Free version of the A* Pathfinding Project

callback will be called when the path has completed. Callback will not be called if the path is canceled (e.g when a new path is requested before the previous one has completed)

+ Here is the call graph for this function:

Path StartPath ( Path  p,
OnPathDelegate  callback = null,
int  graphMask = -1 
)

Call this function to start calculating a path.

Parameters
pThe path to start calculating
callbackThe function to call when the path has been calculated
graphMaskMask used to specify which graphs should be searched for close nodes. See Pathfinding::NNConstraint::graphMask.
A* Pro Feature:
This parameter does not exist or has limited functionality in the Free version of the A* Pathfinding Project

callback will be called when the path has completed. Callback will not be called if the path is canceled (e.g when a new path is requested before the previous one has completed)

+ Here is the call graph for this function:

Member Data Documentation

OnPathDelegate pathCallback

Callback for when a path is completed.

Movement scripts should register to this delegate.
A temporary callback can also be set when calling StartPath, but that delegate will only be called for that path

Examples:
EndingCondition.cs, and MultiTargetPathExample.cs.
bool saveGetNearestHints = true

Saves nearest nodes for previous path to enable faster Get Nearest Node calls.

This variable basically does not a affect anything at the moment. So it is hidden in the inspector

int [] tagPenalties = new int[32]

Penalties for each tag.

Tag 0 which is the default tag, will have added a penalty of tagPenalties[0]. These should only be positive values since the A* algorithm cannot handle negative penalties.

Note
This array should always have a length of 32.
See Also
Pathfinding::Path::tagPenalties
OnPathDelegate tmpPathCallback
private

Temporary callback only called for the current path.

This value is set by the StartPath functions


The documentation for this class was generated from the following file: