Function ABPath.EndPointGridGraphSpecialCase
Applies a special case for grid nodes.
bool EndPointGridGraphSpecialCase (
closestWalkableEndNode | ||
originalEndPoint | ||
int | targetIndex |
Applies a special case for grid nodes.
Assume the closest walkable node is a grid node. We will now apply a special case only for grid graphs. In tile based games, an obstacle often occupies a whole node. When a path is requested to the position of an obstacle (single unwalkable node) the closest walkable node will be one of the 8 nodes surrounding that unwalkable node but that node is not neccessarily the one that is most optimal to walk to so in this special case we mark all nodes around the unwalkable node as targets and when we search and find any one of them we simply exit and set that first node we found to be the 'real' end node because that will be the optimal node (this does not apply in general unless the heuristic is set to None, but for a single unwalkable node it does). This also applies if the nearest node cannot be traversed for some other reason like restricted tags.
True if the workaround was applied. If this happens, new temporary endpoints will have been added
Image below shows paths when this special case is applied. The path goes from the white sphere to the orange box.
Image below shows paths when this special case has been disabled