I was writing code for an npc and came across some issues while using the PathfindingService. My issue was that I was getting waypoints which shouldn’t be possible, with the npc in an enclosed space with no gaps, I even tried using pathfinding modifiers to try and mitigate the issue but it didn’t work. I decided to ask the forums for any help on what’s wrong. (Here’s my original post asking for help)
The issue persists regardless of what the “PathfindingUseImprovedSearch” property on workspace is set to.
I tried to isolate the problem, this video shows the erratic behavior when trying to find a path from the npc to the target part
In the video, you can see that somehow waypoints are showing up in impossible conditions, and they don’t even lead up to the target part accurately, they show up on the baseplate. I deleted the baseplate and at least the issue of waypoints appearing on the baseplate was no longer happening, but the previous issue of waypoints appearing through walls was still happening unfortunately.
I have thoroughly looked through my code for any issues on my end and I can’t seem to figure out what is the problem exactly. I’ve given up and hoping for an answer. I’ve attached a place file with the relevant code and map that is causing the issue in hopes of being helpful in investigating the problem
Expected behavior
I want the Path’s status to be “NoPath” with 0 waypoints. I am not relying on a partial result, but if I do, I may expect the status to be “ClosestNoPath”
I also forgot to mention in the previous post — that I discovered today it also happens with MeshParts and UnionOperations; regular parts with a changed shape enum tend to work best for navigation using PathfindingService.
Maybe try putting invisible hitboxes on unions that the pathfinding can recognize and see if the issue persists? I hope this is a method that can solve your problem.
Edit: Wrong reply / address, I thought I had changed the recipient. I’m new to using the dev forum, so please pardon me if you got a notification, QuackBack.
Faulty navmesh being generated has been causing issues with pathfinding
(The pass through is from the parts of the npc, even if I remove those pathfinding modifiers the issue persists, so the problem isnt the npc itself)
Then the best solution I can think of is to use pathfinding modifiers to manually make an area non-traversable with an invisible part (highlighted red if you wish to debug), so that the AI will try to avoid pathfinding where it shouldn’t.
PathfindingService tends to be biased to navigating NPCs as close to walls as possible — even to the extent where they wall-hug or straight up calculate improper paths, getting them stuck on complex geometry. Often times manual intervention through usage of pathfinding modifiers is needed unfortunately, as much as I like to have things done automatically to save time.
Can you try this to see if the issue persists maybe? I hope this helps or advances a solution to the problem.
I am glad that the part-substitution solution did mitigate the problem with unions and wedges obstructing paths formerly, though.
I have tried using pathfinding modifiers, unfortunately they don’t work. Completely blocking the wall with a CanCollide = true part is the only solution that works, but this requires me to go through every union operation and cover it up with a huge block
If the unions are all instanced with a valid part the PathfindingService can register, it solves the problem with miscalculated paths?
In that case, you could write a script that automatically updates all unions in bulk with an artificial part, so that tedious work won’t be required.
If you’re not sure how to go about it I can share a code sample of my own, but I hope this idea helps to make the process faster and more efficient for you.
You’re welcome, and I hope that this will solve your issue. If it continues to break I’ll try to think of something else, but hopefully this idea will resolve the problem. Good luck!