An introduction to pathfinding
We're going to start by tackling the biggest job: implementing a pathfinding algorithm so that the enemies can move intelligently around the map. Before we do so, let's take a look at pathfinding algorithms as a whole, what they do, and how they do it! This context will help you make the task ahead clearer and show you the wealth of choices that we have.
What is a pathfinding algorithm?
A pathfinding algorithm is an algorithm that calculates the best path from one position to another. A good algorithm will take into account the terrain and several other factors to ensure that the movement is intelligent and won't result in any weird behavior. Remember the last time you were playing a game and an NPC kept walking into the wall? This is the weird behavior that pathfinding errors produce. Every time an enemy runs around an object to get you in a game, it's the result of such an algorithm, and they're essential in the creation of a gameplay that's challenging and...