A* Pathfinding
AStarPathfinder searches a shortest grid path with A*. It supports four-way or diagonal eight-way movement and uses a binary min-heap for efficient open-set operations.
Quick start
1. Scan a scene with AStarGridBaker
Add A Grid Baker* to an empty GameObject, configure the grid size and obstacle layer, and inspect the green walkable/red blocked gizmos in the Scene view.
An unreachable target returns an empty List<Vector2Int>.
Follow a path with AchFollower
Use AchFollower.SetTarget() for simple following. For waypoints, move through the cells in order and clear the target at the end.
2. Create a grid in code
AStarGridBaker settings
Call baker.Bake() after changing dynamic obstacles. Tilemap colliders can be placed on the obstacle layer.
Grid and pathfinder APIs
The returned path excludes the start cell and includes the destination. diagonal defaults to false.
Algorithm details
Diagonal movement permits corner cutting when the diagonal cell is open. Disable diagonal movement or add an adjacent-cell check if that behavior is undesirable.