Pathfinding not working as intended, outputting waypoints that are physically impossible to traverse

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”

A private message is associated with this bug report

3 Likes

Showing a screenshot of the NavMesh visualization may help; it looks like there’s errors in the generation.

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. :folded_hands:

1 Like

I placed a big block over the faulty unions and it does stop being buggy


You can see in the image that there are no waypoints being generated



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.

1 Like

That’s a great idea I didn’t think of that, I think I’ll do as you suggested and cover up the unions with a part at runtime. Thank you so much :folded_hands:

1 Like

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! :slightly_smiling_face:

1 Like

Well it seems the issue still persists. The navigation mesh makes 0 sense. Here is a video showing the issue

Observe how there’s no navigation mesh inside the map, but it exists outside. I’m completely lost on how to fix this issue

2 Likes

Did you ever find a fix. I’m having a similar issue myself?