Class
Path
NotCreatableNotReplicated
Stores the result of paths created by PathfindingService:CreatePath().
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.
Properties 1#
StatusPathStatus | The PathStatus of the generated Path.ReadSafeReadOnlyNotReplicated |
Status: PathStatus#
ReadOnlyNotReplicatedReadSafe
The PathStatus of the generated Path.
Methods 4#
| CheckOcclusionAsync | Checks if a path is blocked starting at a specific waypoint.DeprecatedYields |
| ComputeAsync | Computes a Path from a start position to an end position.Yields |
| GetPointCoordinates | Returns a table of Path instances.Deprecated |
| GetWaypoints | Returns an array of points in the path. |
CheckOcclusionAsync(start: int): int#
YieldsDeprecated
Deprecated. This function has been superseded by the Blocked
event which you can connect to a Path object and should be used instead.
This lets you detect if the path becomes blocked at any time during its
existence.
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.
| Name | Type | Default | Description |
|---|---|---|---|
start | int | The 1-based index of the waypoint from which to begin checking for occlusion. |
Returns
int— The 1-based index of the first blocked waypoint starting fromstart, or-1if the path is not blocked.
ComputeAsync(start: Vector3, finish: Vector3): ()#
Yields
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.
| Name | Type | Default | Description |
|---|---|---|---|
start | Vector3 | The world position where the computed path begins. | |
finish | Vector3 | The world position where the computed path finishes. |
Returns
()
GetPointCoordinates(): Array#
DeprecatedDeprecated
Deprecated. This item has been superseded by
GetWaypoints() which should be used in all new
work instead.
This function returns a table of Path instances.
Returns
Array— An array ofVector3positions for each waypoint in the path.
GetWaypoints(): 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.
Returns
Array— An array ofPathWaypointsordered from path start to path end.
Events 2#
| Blocked | Fires when the computed path becomes blocked. |
| Unblocked | Fires when a computed path that was blocked becomes unblocked. |
Blocked(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.
| Name | Type | Default | Description |
|---|---|---|---|
blockedWaypointIdx | int | The 1-based index of the waypoint at which the path became blocked. |
Unblocked(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.
| Name | Type | Default | Description |
|---|---|---|---|
unblockedWaypointIdx | int | The 1-based index of the waypoint at which the path became unblocked. |
Inherited members#
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild