Pathfinding Modifiers

We have 2 games that use a larger number of NPCs, up to 100 in one game currently in development. I am having a recent problem with the NPCs not seeming to obey Pathfinding Modifiers or even AgentRadius. The modifiers have been added to standard parts, which are then set to transparent and non-collidable for normal players.
Modifier Setup
image

Script Sample

local pathfindingService = game:GetService("PathfindingService")
local pathfindableAreas = workspace.Park.Path:GetChildren()  -- where NPCs can walk to
local pathParameters = {
	AgentRadius = 3,
	AgentHeight = 6,
	AgentCanJump = false,
	Costs = {
		AvoidZone = math.huge,
	}
}
local path = pathfindingService:CreatePath(pathParameters)
while true do
	local nextPathfindableArea = getRandom(pathfindableAreas) --separate functions
	local nextTarget = getRandomInPart(nextPathfindableArea)

	path:ComputeAsync(npc.PrimaryPart.Position, nextTarget)
	local waypoints = path:GetWaypoints()
		
	for _, waypoint in ipairs(waypoints) do
		npc.Humanoid:MoveTo(waypoint.Position)
		if waitUntilTimeout(npc.Humanoid.MoveToFinished, 10) == nil then
			npc.Humanoid:MoveTo(npc.PrimaryPart.Position) 
		end
	end
end

AgentRadius is of sufficient size to stop the NPCs getting stuck on right-angle walls, but seems ineffective.
Pathfinding Modifiers fail to stop the NPCs from wandering through areas they shouldn’t.

An example of this is a narrow gap between 2 escalators that I don’t want them to traverse, so a part with a Modifier is placed in the gap. The NPCs then proceed to try to enter the narrow gap, getting stuck on the way.

Where am I going wrong? I tried setting the material of the parts to Lava to see if I could use Material to influence the Modifier, but that didn’t work either. The parts themselves are over 11 studs high.

You can see this behaviour in action on our Monkey Poop game. The visitors to the zoo should not be walking on the walls beside the enclosure as they are covered by parts with Modifiers over them, but they always seem to ignore the modifiers.

I’m actually using heavily modified version of Justice by #LewisTehMinerz (thanks Lewi), but even stand alone Pathfinding like the above seems to be ignoring the AgentRadius & Pathfinding Modifiers.

I have now fixed the Pathfinding Modifiers issue.

When you add a PathfindingModifier to a Part, you need to ensure that the CanQuery property of the part is set to Enabled. Failure to do this will result in the Modifier being ignored by Pathfinding when calculating a path.

I will try to get Roblox to update their documentation, as this is never stated as a requirement.

7 Likes