Center pathfinding in area

Hi,

I’ve been trying to use PathfindingService for a while now, however I’m noticing a problem – it keeps hugging walls. I get why it does this and why it would, especially in open areas, however, I have hallways and want it to try center along the hallways.

These purple dots are the places where it pathfinds to, and are equidistant from the wall. I thought of using PathfindingModifiers and setting the weight to something low (0.1) to try and make it want to go to the dots, however it ended up avoiding them even more. Does anyone know how I could try make the pathfinding aim for the middle?

thanks

Adjusting the Agent Radius should help you solve this problem

2 Likes

But then if I end up having any bottlenecks (i.e. putting props in the hallway) then it wont be able to go through them), and if I were to decrease the AgentRadius to adjust for this then I’d end up with the first problem again

There’s a trick for this that does actually work but it’s a bit complicated to learn how to do. You need to have two collision groups available for monsters. One of them is the standard one where monsters get stuck on walls because they collide with them. The other one that you need to add is the bonus one where it allows the monsters specifically to noclip through the walls and then you can simply revert it back a few seconds afterwards.

Could you provide an example?

30

Sure. The way I do it is I add a script into the killer called “Noclip” and I check if the killer isn’t moving further than a certain amount of studs and if they aren’t you just give the walls the group that allows killers to noclip through them

while true do

local oldCFrame = script.Parent.HumanoidRootPart.CFrame.Position
task.wait(1)
local newCFrame = script.Parent.HumanoidRootPart.CFrame.Position

if (oldCFrame - newCFrame).Magnitude < 4 then

for i, v in pairs(workspace.Architecture.Map:GetDescendants()) do
if v:IsA("Part") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("WedgePart") then
v.CollisionGroup = "Noclip"
end
end

task.wait(3)

for i, v in pairs(workspace.Architecture.Map:GetDescendants()) do
if v:IsA("Part") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("WedgePart") then
v.CollisionGroup = "Default"
end
end

end

task.wait(1)
oldCFrame = newCFrame

end

So ideally you want to make a entity like fraud? Well they used A* pathfinding which I suggest you look into, place your own nodes like you have in the video and look into A* in community creations on the devforum.

So hacky and tricky to do with base roblox pathfinding it is just NOT worthit.

2 Likes

Well it just depends what they are looking for. I really didn’t care about it being perfect when I made my pathfinding killer and so for me it was easier to just let them noclip through walls whenever they get stuck. It’s a nice little work around. You can also make them teleport when they get stuck. I agree A* is tricky but if you are looking for something presentable to thousands of people then it would require many hours of learning it.

Yeah, I’ve made A* before – I’ll try port it over
Thanks so much everyone

1 Like

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