Join Jesse Freeman for an in-depth discussion in this video What is a node?, part of Unity 5 2D: Pathfinding.
- A node is the basic building block of our pathfinding algorithm. We use the node to represent each space in the map and its relationship to its neighbors. The node is a critical part of the entire algorithm. So let's look at how to build out our first node class. Inside of our scripts folder, let's create a new C# script and we're going to call this node. Then, let's open this up in MonoDevelop. As we build out the node we're going to need to keep a list of all the neighbors that the node is surrounded by. In order to do that, let's change our system collections at the top of our class to systems collections generic so we can have access to the list later on.
Next, since our node isn't going to be represented by a game object itself, there's no reason for us to extend Mono behavior so let's delete that. And also you can delete the start and update methods. Let's save our script, at this point we now have the basic shell for our node and in the next video we'll talk about the properties that make the node work.
- What is A*?
- Adding node classes and properties
- Storing and indexing graph nodes
- Building the search class
- Traversing the nodes
- Searching adjacent nodes
- Testing the search
- Building a test map
- Creating and coloring a grid