Difference between revisions of "API:Class/Path/GetWaypoints"

< API:Class‎ | Path
(Created page with "{{APIMemberPage |DescriptionShort=Returns an array of points in the path. |Description=The GetWaypoints function returns an array of all the {{api|PathWaypoint}}s in its {{api...")
 
 
Line 1: Line 1:
 
{{APIMemberPage
 
{{APIMemberPage
 +
|TypeArgs.return=Class/PathWaypoint
 
|DescriptionShort=Returns an array of points in the path.
 
|DescriptionShort=Returns an array of points in the path.
 
|Description=The GetWaypoints function returns an array of all the {{api|PathWaypoint}}s in its {{api|Path}}. The array is arranged in the order of the waypoints in the path.
 
|Description=The GetWaypoints function returns an array of all the {{api|PathWaypoint}}s in its {{api|Path}}. The array is arranged in the order of the waypoints in the path.

Latest revision as of 23:33, 5 October 2017

GetWaypoints

Function of NavPath.pngPath
array<PathWaypoint> GetWaypoints ()

Returns: array<PathWaypoint>
Description: The GetWaypoints function returns an array of all the PathWaypoints in its Path. The array is arranged in the order of the waypoints in the path.

If a path was not able to be found, GetWaypoints will return an empty array.

Example

local PathfindingService = game:GetService("PathfindingService")
 
local start = Vector3.new(0, 1, 0)
local finish = Vector3.new(100, 1, 25)
 
local path = PathfindingService:FindPathAsync(start, finish)
local waypoints = path:GetWaypoints() 
for waypointIndex, waypoint in pairs(waypoints) do
	print("Waypoint", waypointIndex, ":", waypoint.Position)
end