A* pathfinding not returning shortest path with weird behavior

The A* pathfinding algorithm works fine most of the time but in some specific cases, it seems to not use the shortest path.

For example,

Legend

  • N = Start point

  • E = Endpoint

  • | = obstacle

  • (-) supposed movement path

  • = How it moves

  • D = move down

  • U = move up

              _ _ _ _
              |     |
              |   | |
       N(-)(-)(-)U|E
       D         U|
       D         U|
       D > > > >>U|
    

End of diagram and assume that all the other paths are blocked and that the three (-) (-) (-) direction is the shortest path to the end. In this specific instance, it chooses to take the longer path represented by >>>>> UUUUU instead of (-)x3.

Hi

Do you think you could post a screenshot of your graph?
Are you using a grid graph or a navmesh/recast graph?