I’m building a game that allows the player to build buildings that the NPCs can navigate, and it basically works using a recast graph that recalculates the mesh when I add or remove geometry. The graph calculates correctly, but the pathing fails in some cases:
One of the basic tests I’ve been running is on stairs, which my npc will not navigate up unless they are lined up directly straight with them. So if the path calls for them to approach the stairs, say, from the left, it’ll get to the bottom of the stairs, then hang near the bottom, instead of walking around the small edge, and up the stairs: https://imgur.com/edeb6IB
Similarly if the player builds a block of geometry that’s between the NPC the player, the NPCs plans a path over the block, which is actually correct since the block is low enough, then it hangs indefinitely, just walking forward in the same position against the geometry forever: https://imgur.com/dPMNhKd
In both of those cases the destination is supposed to be reachable, but the NPC never makes it there because it’s hung. I also notice the green path is quite goofy, it’s sort of jagged and goes in a lot of directions, instead of being a clean path to the destination.
If I line up the stairs to be a straight path from the starting point to the stairs, then a straight path from there to the destination, that also works fine.
On the other hand, if the blocks are high enough not to be reachable, the NPC will navigate around the geometry correctly: https://imgur.com/9A1eGnl
What am I doing wrong?