Getting complete path to location I cannot reach in grid graph


I’m working on game that uses grid graph. With enemy AI, I use ABPath to try to figure out if target character can be reached and what is the shortest path to it.

However, when trying to find the path to enemy I get into following situation.
The vertical lines mean following:

  • Green: The target I give to my AI path (where the target character is located)
  • Blue: End node of the path returned
  • Red: End position of the path returned
  • White short ones: path points (path points going other direction are paths to other evaluated characters)

The path returns complete for me offering path (red arrow), when I actually think I should get the path like green arrow there in this case as I should not be able to move from node with blue vertical line to node with green vertical line due to height difference.

The path is requested with following

            var path = ABPath.Construct(source, target);
            path.nnConstraint = GetPathConstraint();
            AstarPath.StartPath(path, pushToFront);

and constraints I use are

   pathConstraints = new SampoNNConstraint()
                constrainWalkability = true,
                walkable = true,
                EntityId = _characterEntity.EntityId,
                constrainArea = true,
                area = (int)characterEntity.GetNavigationData().NavigationAreaId

Any thoughts what I’m not figuring out here and how I could get desired result and the path to be calculated matching more the green arrow?

I’m currently using version 4.3.70 of A* Pathfinding Project.

Hi, @aron_granberg any advices about this one?


The path will always go to the closest node to the destination that can be reached.
In this case, to me, it looks like the green ray should be reachable, so I’m not sure why it doesn’t generate a path all the way to the green ray. But there might be obstacles along the way that I cannot see in the screenshot.