How to make PathfindingService not hug walls

I’ve been messing around with pathfinding but the npc keeps hugging the wall all the time, is there a way to fix this?

1 Like

Pathfinding usually tries to make the path as short as possible. This is why it will end up getting closer to the walls. You can keep more of a distance from the walls by increasing the agent radius parameter. This essentially tells the pathfinder that the character is wider.

1 Like

Watch TheDevKing’s tutorial on pathfinding, it is pretty helpful.

as @Emskipo said above,
make the agent radius bigger

local PathfindingService = game:GetService("PathfindingService")
 
local path = PathfindingService:CreatePath({
	AgentRadius = 5, --studs
})
2 Likes