Pathfinding does not allow NPC to traverse obvious traversable space

This was originally reported in 2023, and was marked as being fixed, however, the issue is still present: Pathfinding does not allow NPC to travel through obvious traversable space

You have to make the AgentRadius smaller than 2, otherwise the NPC will refuse to go to it’s goal, in this case, the player. It seems that if the gap is not exactly 6 studs wide, the NPC will not traverse it. The stairs and catwalk are both 6 & 7 studs wide, respectfully.

Agent Radius set to 2:

Repro File:
ReproFile.rbxl (77.4 KB)

EDIT
After doing a little bit of testing, it seems that this is due to a very skinny part being in the way of the pathfinding, instead of the pathfinding service going “between” the two walls in the repro file, they want to go into the corner for some reason. The NPC should always go directly in the middle instead of trying to cut the corner.

The AI wants to walk into the corner, which is why the path fails:

Expected behavior

I expect the NPC to be able to smoothly traverse to the player if the gap is wider than it’s agent radius.

For example, this is with the agent radius set to 1.5 (which causes the NPC to get stuck on things occasionally because it’s actually 2 studs wide.)

2 Likes

Salutations!

Thanks for bringing this to our attention.
A ticket was filed, but we’ll need more information about it.

Please provide a log and a Repro Placefile so we can investigate it right away.

If you need assistance or info on how to get them, please refer to the How to post a Bug Report - Bug Reports - Developer Forum | Roblox

Thanks for understanding!
Have A Nice Day!

1 Like

Sure thing!

I’ve added a repro file to the original post, however, I don’t think a log file is necessary.

1 Like

Noticed similar issues

1 Like

The repro place is not using the ImprovedSearch on pathfinding, (which for the most part fixes the corner issue in many cases). However, when testing with both ImprovedSearch on and off the path status returns “NoPath”, this is because the diameter of the Navmesh in the doorway is only 2 studs wide. As your agent radius is 2 the diameter of the agent is 4 studs thus he doesn’t fit, your agent radius must be 1 stud if you want him to pass within this small gap. It is more so that the Navmesh generation is quite poor, but this is the case with many things, especially stair cases.

1 Like

The navmesh generation being poor would most likely be the culprit, yeah.

Still, I feel like the NavMesh generation should be a lot more accurate.

It seems to operate under the assumption that everything is at least a stud wide.

Your code is very outdated and is running very slow.
First you need to set up improved search under workspace properties.
Then you have to change agent radius to 1 for it to work(Radius is half of the diameter) and works on your npc.
here is a better code:

--Import the module so you can start using it
local ServerStorage = game:GetService("ServerStorage")
local SimplePath = game:GetService("PathfindingService")

--Define npc
local Dummy = script.Parent

-- Define a part called "Goal"
local Goal = workspace.Goal

local AgentParameters = {
	AgentRadius = 1,
	AgentHeight = 5,
	AgentCanJump = false,
	AgentCanClimb = true,
}

--Create a new Path using the Dummy
local Path = SimplePath:CreatePath(AgentParameters)

function moveTo()
	Path:ComputeAsync(Dummy.HumanoidRootPart.Position, Goal.Position)
	if Path.Status ~= Enum.PathStatus.NoPath then
		if #Path:GetWaypoints() >= 3 then
			Dummy.Humanoid:MoveTo(Path:GetWaypoints()[3].Position)
		end
	end
end

while task.wait() do
	moveTo()
end

Changing the agent radius to 1, despite it actually being 2 seems like a bandaid fix, which is exactly what Roblox should fix.