Pathfinding errors

I’m having some issues where I’m getting bad paths on a recast graph. This image shows an example of this:

The green line, the path, is cutting right across impassable terrain and over a large gap to arrive at it’s destination.

Any idea what’s going on?

Just looking at this picture alone I do see quite a few holes in the Recast graph already.

Though that doesn’t necessarily mean that that is the issue we’re looking for.

1 Like

Hi

Are you using any path modifiers?

Yes, I am using the funneling modifier.

Holes? Not that I’ve noticed. The recast graph seems valid as far as I can tell. The image is hard to interpret since the graph display overlays the various geometry… but it’s valid. The path in question was correct for about 80% of it’s length and then near the end, it just seemed to say “meh… I’ll just go straight to the end from here.”

These definitely look undesired.

I think that is because the terrain undulates at such points. But in any case, that’d just mean those are impassable, right? That wouldn’t explain what’s happening.

I looked at these spots in the nav mesh, and… yeah… they are not quite right. I played with several recast settings, and made it different but not better. Nothing odd about the terrain at this spot that I can tell. Not sure how to fix.

Also, not sure it is related or not to the problem of navigating giving the invalid path.

Usually holes like this indicate something went wrong during generation of the graph, which could result in bad node connections. Resulting in the system wrongly calculating paths.
Would you mind sending me your cached graph, I’ll see if I can reproduce it on my side.
I’ll dm you contact email :slight_smile:

Good news is that I was able to reproduce the issue:


I’ll investigate this closer and see if I can find the root of this problem

Although it visually might shows some oddities. (RichAI does some simplification internally, which might yield in these visual problems)
I didn’t have any problem with the agents walking across the map at all.

These holes that I’ve mentioned before should most likely be addressed though, they don’t seem to be a problem at the moment, but I’d be careful with this stuff. ( Connections from these nodes do look fine )

So the “holes” are not an issue per se, but the pathfinding solution error still is, correct?

Not really,
Like I said, it’s more of a ‘visual’ issue.

I made this small sketch in Paint to illustrate what I think is going on:

The path goes from the Bottom left corner to the Top right corner. A -> B -> F However there is a funnel modification happening on this system. The funnel considers this to be ‘direct’ enough to just go straight ( Skip B ). And thus the line is being drawn Connecting A -> F.
Pathfinding with A* is technically always 2D and every path could be shown from a perpendicular view to the navigation plane. But the game is in 3D so we can see these ‘2D -> 3D’ artifacts as shown in the side view.

This is my take on it. As I had the agent walk from one side to the map, to the other with different starting and end points. Though there were visual issues ( like described ) there were no noticeable navigation issues.

Perhaps I should have been more clear in this example. The Agent was located left bottom, and was traveling to the visual destination on the image. The path does show a direct cut near the end. But as the agent got closer ( path was being recalculated every 0.5 seconds ) The direct cut was shortened and eventually disappeared. The agent walked correctly to the destination.

Maybe that’s the issue. I’m not recalculating the path constantly. I presume I should be?

I suspect this is due to the funnel modifier. It’s kinda hard to see in this case.
If you want the funnel modifier to not straighten out the path along the Y coordinate you can check the splitAtEveryPortal setting on the funnel modifier.

All those gaps in the navmesh look bigger than usual though… Possibly you should try to increase the resolution of the recast graph.

I played with the resolution and various other settings and never got the holes to vanish.

I found that having the path regeenerate every half second, in my case, it fixes the pathing/funneling issues as it goes. Seems like this should be unecessary, but it has the side-benefit of dealing with unexpected situations like being pushed off path (falling off a ledge, etc.). The character controller is never going to match the pathing algorithm’s thinking of what can be navigated exactly, so this seems to be the answer and will work for my needs.