Pathfinding service creating unnecessary waypoints

I’m using the pathfinding service to make npcs walk from part to part and I’ve notice that it’s generating the waypoints in a way that makes it very inefficient for the npc to walk to the destination.
Here’s what I mean: This shows the path the npc should take (blue), compared to the path that the npc actually takes (purple)

Here’s another example: The npc is walking from the yellow part to the green part but takes an unnecessary detour.

Instead of going in a straight line from A to B, it jumps over the stair railing, struggles to climb up the stairs and finally onto B. How can I make it so that it takes the most efficient route to B?

Here’s the waypoint generation code if you want to see. Just normal waypoint generation.

local path = PathFinding:CreatePath()
path:ComputeAsync(npc.HumanoidRootPart.Position, tycoon.Pathfinding[PfPartData2.Object].Position)
local waypoints = path:GetWaypoints()
for _, waypoint in pairs(waypoints) do
	npc.Humanoid:MoveTo(waypoint.Position)			
end
1 Like

Hello,

By looking at the ground in your video, it might be a simple case that the service is not very happy with the different parts being not in line. So try re-aligning the parts on the floor or moving different parts around.

Let me know if this helps!

Didn’t work. I moved around the parts a bit and the Pathfinding service was just determined that the npc was going to eat chairs and stair railings. I ended up just making my own waypoints instead.

1 Like