Pathfind to nearest walkable node 2D

Hi,
I’m attempting to use A* Pathfinding free version and GridGraph to do pathfinding on a 2d, top-down, sprite based map. Everything is working nicely, except one thing – I need to be able to choose to create a path to an “obstacle” (something that blocks pathfinding), and have it give me a path to the closest walkable node. I thought I should be able to do this using the start-end modifiers, however it is always determining the closest node as the one closest to 0 in y-value. I have tried every exactness modifier available, it yields the same result. Below is a picture of an incorrect path it generates for me, when I use StartPath. I am attempting to create a path to the grey brick tile.

This is NOT correct, the closest tile to the grey tile is the one directly above the grey tile, but it still gives me a path to the one directly below the grey tile.

No matter what direction I path to the tile from (diagonals included), it gives me a path to the tile below the obstacle, and I do not understand why. Am I missing something obvious?

Hi

The pathfinding scripts normally find a path from the closest node to the start point to the closest node to the end point. Normally there is only a single end point with the smallest distance (because of floating point errors and such things). E.g the bottom node might be closer by 0.0001 so it will move to it because it is closer to the point you requested.

However a few people have been complaining about this, so in my dev version I have implemented a special case for grid graphs when the target point is on top of a single blocked node, it will now pick the best node of the 8 neighbours. I have not released that version yet, but I could send you my internal dev build if you are interested.

It would prove useful if you wouldn’t mind, it does somewhat inhibit pathfinding for this case. Is the fix going to appear in a release version any time soon?

Hi

Sorry for the late answer.
I have sent a PM with the latest dev version.