Class · inherits Instance
Path
Stores the result of paths created by PathfindingService.CreatePath.
About Path
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
Status
: PathStatusReadOnlyNotReplicatedThePathStatusof the generatedPath.
Methods 2
ComputeAsync
(start: Vector3, finish: Vector3) → ()YieldsComputes aPathfrom a start position to an end position.This function computes a
Pathfrom 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.GetWaypoints
() → ArrayReturns an array of points in the path.This method returns an array of all the
PathWaypointsin aPathas computed byComputeAsync().Each waypoint in the array specifies a
Vector3position andPathWaypointActionto 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.
Events 2
Blocked
Path.Blocked:Connect(function(blockedWaypointIdx))Fires when the computed path becomes blocked.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.
Unblocked
Path.Unblocked:Connect(function(unblockedWaypointIdx))Fires when a computed path that was blocked becomes unblocked.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.
Path also has every member of Instance. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.