Learning Pathfinding

Im trying to learn pathfinding and i found this script and Im trying to break it down so I understand it

local pfs = game:GetService(“PathfindingService”)
local NPC = script.Parent
local part = workspace.Destination

local path = pfs:CreatePath({AgentCanJump = true})
path:ComputeAsync(NPC.HumanoidRootPart.Position,part.Position)

Can anyone Explain what this part about waypoints means?
for _, waypoint in pairs(path:GetWaypoints()) do
NPC.Humanoid:MoveTo(waypoint.Position)
NPC.Humanoid.MoveToFinished:Wait()

end

the pathfinding service creates waypoints that form a path for an “npc” to navigate in order to get to the targetted position. The idea is that you can loop through this list of waypoints and mvoe the humanoid from node to node to simulate walking the path

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.