Path
Stores the result of paths created by PathfindingService:CreatePath().
| Memory category | Instances |
|---|
Member index 7
Description
Path objects store the result of paths created by
PathfindingService:CreatePath().
Once a Path object is created, you can call
ComputeAsync() with a starting point and ending
point. This will attempt to compute a valid path for a character to move
along, based on default or custom parameters passed to
CreatePath(). If
ComputeAsync() successfully finds a path, the
Path object will have a Status value of
PathStatus.Success. Otherwise the status will be
PathStatus.NoPath which can occur if there are obstacles between the
two points (and no way around) or if the points are inside of solid objects.
In addition to ComputeAsync(), Path objects have
the GetWaypoints() method which returns a list of
waypoints representing the points a character should follow in sequence to get
from the beginning to the end of the path.
Finally, Path objects can be connected to the
Blocked event which will fire if, at any time during the
path's existence, the path is blocked. Note that this can occur behind a
character moving along the path, not just in front of it.
See Pathfinding for details on implementing character pathfinding.
History 19
- 573 Change ReturnType of ComputeAsync from void to null
- 553 Change PreferredDescriptor of GetPointCoordinates from to GetWaypoints
- 553 Change Default of Status from to
- 491 Add Unblocked
- 486 Change ThreadSafety of Status from ReadOnly to ReadSafe
- 462 Change ThreadSafety of Blocked from to Unsafe
- 462 Change ThreadSafety of GetWaypoints from to Unsafe
- 462 Change ThreadSafety of GetPointCoordinates from to Unsafe
- 462 Change ThreadSafety of ComputeAsync from to Unsafe
- 462 Change ThreadSafety of CheckOcclusionAsync from to Unsafe
- 462 Change ThreadSafety of Status from to ReadOnly
- 359 Add Blocked
- 359 Add ComputeAsync
- 309 Add GetWaypoints
- 309 Change Tags of GetPointCoordinates from [] to [Deprecated]
- 158 Add GetPointCoordinates
- 158 Add CheckOcclusionAsync
- 158 Add Status
- 158 Add Path
Members 7
Blocked
| Parameters (1) | |
|---|---|
| blockedWaypointIdx | int |
Fires when the computed path becomes blocked. Note that paths may become blocked somewhere behind the agent, such as a pile of rubble falling on a path as the agent runs away. See blocked paths for details on checking the forward waypoint progress of an agent along a path.
| Thread safety | Unsafe |
|---|
CheckOcclusionAsync
| Parameters (1) | ||
|---|---|---|
| start | int | |
| Returns (1) | ||
| int | ||
This function checks if a path is blocked starting at the waypoint indicated by start.
It returns the first waypoint of occlusion if blocked, -1 if not. it
returns an error if start is less than 0 or greater than the number of
waypoints in the Path.
| Thread safety | Unsafe |
|---|
History 2
- 462 Change ThreadSafety of CheckOcclusionAsync from to Unsafe
- 158 Add CheckOcclusionAsync
ComputeAsync
| Parameters (2) | ||
|---|---|---|
| start | Vector3 | |
| finish | Vector3 | |
| Returns (1) | ||
| null | ||
This function computes a Path from a start position to an end position.
This function is not automatically called when a path is created and must
be invoked each time the path needs to be updated.
Once the path is computed, it will have a series of waypoints that, when followed, can lead a character along the path. These points are gathered with the GetWaypoints() function.
| Thread safety | Unsafe |
|---|
History 3
- 573 Change ReturnType of ComputeAsync from void to null
- 462 Change ThreadSafety of ComputeAsync from to Unsafe
- 359 Add ComputeAsync
GetPointCoordinates
| Parameters (0) | ||
|---|---|---|
| No parameters. | ||
| Returns (1) | ||
| Array | ||
This function returns a table of Path instances.
| Thread safety | Unsafe |
|---|
History 4
- 553 Change PreferredDescriptor of GetPointCoordinates from to GetWaypoints
- 462 Change ThreadSafety of GetPointCoordinates from to Unsafe
- 309 Change Tags of GetPointCoordinates from [] to [Deprecated]
- 158 Add GetPointCoordinates
GetWaypoints
| Parameters (0) | ||
|---|---|---|
| No parameters. | ||
| Returns (1) | ||
| Array | ||
This method returns an array of all the
PathWaypoints in a Path as computed by
ComputeAsync().
Each waypoint in the array specifies a Vector3 position and PathWaypointAction to take when the waypoint is reached. The array is arranged in the order of waypoints from the path start to path end.
If a path could not be computed, this function will return an empty array.
| Thread safety | Unsafe |
|---|
History 2
- 462 Change ThreadSafety of GetWaypoints from to Unsafe
- 309 Add GetWaypoints
Status
| Type | Default | |
|---|---|---|
| PathStatus | ||
The PathStatus of the generated Path.
| Thread safety | ReadSafe |
|---|---|
| Category | Data |
| Loaded/Saved | false/true |
Unblocked
| Parameters (1) | |
|---|---|
| unblockedWaypointIdx | int |
Fires when a computed path that was blocked becomes unblocked. Note that a blocked path may become unblocked somewhere behind the agent, effectively making reaction to this event unnecessary. See blocked paths for details on checking the forward waypoint progress of an agent along a path.
| Thread safety | Unsafe |
|---|