A* Pathfinding Project
4.1.11
The A* Pathfinding Project for Unity 3D
|
Adjusts start and end points of a path. More...
Adjusts start and end points of a path.
This modifier is included in the Seeker component and is always used if you are using a Seeker. When a path is calculated the resulting path will only be the positions of the nodes it passes through. However often you may not want to navigate to the center of a specific node but instead to a point on the surface of a node. This modifier will adjust the endpoints of the path.
Public Types | |
enum | Exactness { SnapToNode, Original, Interpolate, ClosestOnNode, NodeConnection } |
Sets where the start and end points of a path should be placed. More... | |
Public Member Functions | |
override void | Apply (Path _p) |
Main Post-Processing function. More... | |
Public Member Functions inherited from PathModifier | |
void | Awake (Seeker seeker) |
void | OnDestroy (Seeker seeker) |
virtual void | PreProcess (Path path) |
Public Attributes | |
bool | addPoints |
Add points to the path instead of replacing them. More... | |
System.Func< Vector3 > | adjustStartPoint |
Will be called when a path is processed. More... | |
Exactness | exactEndPoint = Exactness.ClosestOnNode |
How the end point of the path will be determined. More... | |
Exactness | exactStartPoint = Exactness.ClosestOnNode |
How the start point of the path will be determined. More... | |
LayerMask | mask = -1 |
bool | useGraphRaycasting |
Do a straight line check from the node's center to the point determined by the Exactness. More... | |
bool | useRaycasting |
Do a straight line check from the node's center to the point determined by the Exactness. More... | |
Public Attributes inherited from PathModifier | |
Seeker | seeker |
Protected Member Functions | |
Vector3 | GetClampedPoint (Vector3 from, Vector3 to, GraphNode hint) |
Properties | |
override int | Order [get] |
Properties inherited from PathModifier | |
abstract int | Order [get] |
Modifiers will be executed from lower order to higher order. More... | |
Properties inherited from IPathModifier | |
int | Order [get] |
Private Member Functions | |
Vector3 | Snap (ABPath path, Exactness mode, bool start, out bool forceAddPoint) |
Private Attributes | |
List< GraphNode > | connectionBuffer |
System.Action< GraphNode > | connectionBufferAddDelegate |
|
strong |
Sets where the start and end points of a path should be placed.
Here is a legend showing what the different items in the above images represent. The images above show a path coming in from the top left corner and ending at a node next to an obstacle as well as 2 different possible end points of the path and how they would be modified.
Enumerator | |
---|---|
SnapToNode | The point is snapped to the position of the first/last node in the path. Use this if your game is very tile based and you want your agents to stop precisely at the center of the nodes. If you recalculate the path while the agent is moving you may want the start point snapping to be ClosestOnNode and the end point snapping to be SnapToNode however as while an agent is moving it will likely not be right at the center of a node.
|
Original | The point is set to the exact point which was passed when creating the path request. Note that if a path was for example requested to a point inside an obstacle, then the last point of the path will be inside that obstacle, which is usually not what you want. Consider using the #ClosestOnNode option instead.
|
Interpolate | The point is set to the closest point on the line between either the two first points or the two last points. Usually you will want to use the NodeConnection mode instead since that is usually the behaviour that you really want. This mode exists mostly for compatibility reasons.
|
ClosestOnNode | The point is set to the closest point on the surface of the node. Note that some node types (point nodes) do not have a surface, so the "closest point" is simply the node's position which makes this identical to #Exactness.SnapToNode. This is the mode that you almost always want to use in a free movement 3D world. |
NodeConnection | The point is set to the closest point on one of the connections from the start/end node. This mode may be useful in a grid based or point graph based world when using the AILerp script.
|
|
virtual |
Main Post-Processing function.
Implements PathModifier.
|
protected |
bool addPoints |
Add points to the path instead of replacing them.
If for example exactEndPoint is set to ClosestOnNode then the path will be modified so that the path goes first to the center of the last node in the path and then goes to the closest point on the node to the end point in the path request.
If this is false however then the relevant points in the path will simply be replaced. In the above example the path would go directly to the closest point on the node without passing through the center of the node.
System.Func<Vector3> adjustStartPoint |
Will be called when a path is processed.
The value which is returned will be used as the start point of the path and potentially clamped depending on the value of the exactStartPoint field. Only used for the Original, Interpolate and NodeConnection modes.
|
private |
|
private |
Exactness exactEndPoint = Exactness.ClosestOnNode |
How the end point of the path will be determined.
Exactness exactStartPoint = Exactness.ClosestOnNode |
How the start point of the path will be determined.
LayerMask mask = -1 |
bool useGraphRaycasting |
Do a straight line check from the node's center to the point determined by the Exactness.
bool useRaycasting |
Do a straight line check from the node's center to the point determined by the Exactness.
There are very few cases where you will want to use this. It is mostly here for backwards compatibility reasons.
|
get |