I’d like to make my NPC move from point A to point B first, then move to point C to carry out a supposed function, afterwards it’ll head back to point B and to point A.
I do understand pathfinding to a certain extent, but I’m not sure how to apply it for such a scenario. I’ve tried agent costs but it doesn’t seem to work. I don’t want the NPC to take a shortcut.
you can make an array of checkpoints to loop through and use pathfinding agent on each point like this:
local destinations = {PointA,PointB,PointC,PointB,PointA}
for _,destination in pairs(destinations) do
local waypoints --insert your pathfinding code here
for _,point in pairs(waypoints) do
Humanoid:MoveTo(point.Position)
Humanoid.MoveToFinished:wait()
end
end