PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

GetWaypoints

The GetWaypoints() function returns an array of all the path waypoints in a Path, as computed by Path/ComputeAsync|Path:ComputeAsync(). 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

Return Type Summary

An array of waypoints.


Code Samples


Path:GetWaypoints

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