PathFindingService wonky paths

I currently use ComputeAsync for my NPC’s pathfindings and I suddenly stumbled upon this weird thing about it where moving certain parts changes which part they take?

Is there a way I can perhaps like set it up so they take the quickest way possible to certain position?

for _, waypoint in waypoints do
        local path = PathfindingService:CreatePath({
            AgentRadius = 2,
            AgentHeight = 2.5,
            AgentCanJump = true
        })

        path:ComputeAsync(enemy.PrimaryPart.Position, waypoint.point.Position)
        if path.Status == Enum.PathStatus.Success then
            local waypoints = path:GetWaypoints()
            for _, point in waypoints do
                Humanoid:MoveTo(point.Position)
                Humanoid.MoveToFinished:Wait()
            end
        end
    end
2 Likes

For TD games I recommend just placing down the waypoints yourself, not only can you avoid Roblox’s pathfinding with this you will also get some benefits like better performance and more customizability.
(For the actual problem I have no idea on how to fix it)

2 Likes

Here is where Costs come in, if you do not want them to touch avoid Grass for example you’d do:

Costs = {
		Grass = math.huge,
	},

This will ensure the path created steers towards the path with the material of the lowest ‘Cost’.

1 Like