Next up, we'll be implementing the A* algorithm in a Unity environment using C#. The A* Pathfinding algorithm is widely used in games and interactive applications even though there are other algorithms, such as Dijkstra's algorithm, because of its simplicity and effectiveness. We've briefly covered this algorithm previously in Chapter 1, The Basics of AI in Games, but let's review the algorithm again from an implementation perspective.
Let's review the A* algorithm again before we proceed to implement it in the next section. First, we'll need to represent the map in a traversable data structure. While many structures are possible, for this example, we will use a 2D grid array. We'll implement the GridManager
class later to handle this map information. Our GridManager
class will keep a list of the Node
objects that are basically titles in a 2D grid. So, we need to implement that Node
class to handle things such as node type (whether it's a traversable...