How to make PathfindingService compute path only to certain parts?

So the title may be a little confusing, since I’m not a native english speaker but I’ll try to explain it as best as I can. So I have a relatively medium-large sized map.

And in my theory, that because each wall has decorations and such, that it might cause Pathfinding to bug out (correct me if I’m wrong here).

image

So I was wondering if I can somehow make the pathfinding Ignore all map parts and only react to these simple grey walls

Kind of like using Raycast’s FilterType property

So like would this be possible with Pathfinding itself or would I have to completely make a custom pathfinding system like A*?

Im desperate as hell for a fix, in fact this is a repost from this post in a way.

If the pathfinder AI chases players, then that might be a problem for the pathfinder. But neither cases should bug out the pathfinder; though you can use a bigger collider block (or just disable the collisions on the decorations as that also consumes memory)

the Pathfinding Modifier’s PassThrough property might be the thing you need

I have thought of that, but thought maybe there’s a better way to do it. Suppose I’ll try it out and see how it works.

1 Like

I might be actually using PS wrong here, cause when I fire the :AdvanceDistance(), it returns with 0 waypoints?

This is the code:

function module:AdvanceDistance(p1, p2, extraPathData)
	local path = PathfindingService:CreatePath(extraPathData)
	
	path:ComputeAsync(p1, p2)

	local waypoints = path:GetWaypoints()
	print(#waypoints)

	local totalDistance = 0

	for i, waypoint in pairs(waypoints) do
		local nextWP = waypoints[i + 1]
		if nextWP then
			totalDistance += (waypoint.Position - nextWP.Position).Magnitude
		end
	end
	
	return totalDistance, waypoints
end

This is where it gets called from:

local function properMoveTo(p1, p2, humanoid)
	local distance, waypoints = LocalAPI:AdvanceDistance(p1, p2, PathfindingData)
	local targetWaypoint = waypoints[PathfindingSettings.SkipToWP]
	warn(distance, waypoints)
	
	for _, v in pairs(waypoints) do
		debugg(v.Position)
	end

	if targetWaypoint then
		warn(LocalAPI:GetDistance(p1, targetWaypoint.Position), "target wp", #waypoints)
		debugg(targetWaypoint.Position)
		humanoid:MoveTo(targetWaypoint.Position)
	else
		warn(LocalAPI:GetDistance(p1, p2), "no target")
		debugg(p2)
		humanoid:MoveTo(p2)
	end
	print("a")
end

Output shows: 0 {}
0 Being the distance from p1 and p2 according to waypoints, and {} is the table of the waypoints.

It may be because the path is unreachable/impossible for the pathfinder to find one valid solution (check the environment and your extra path data), try printing the path status enum

Yup likely is, returned as “NoPath”

1 Like

are you sure from the starting point to the destination is reachable? can you provide the pathfinder agent parameters and a screenshot of the starting point and the destination?

The map is entirely basically a maze, the starting point is somewhat center of the map and destination is a random waypoint out of ~100. Also I got it to partially work, apparently AgentHeight was messing it up a bit. But it’s still iffy, however I’ll try maybe messing with the params to possibly get a fix

1 Like

I think I got it to work, I’mma try sum to check
Edit: Yup I fixed it, technically fixed it myself but I’ll give @Artzified the solution cause you helped me out still

1 Like

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