As we have seen in the previous chapter, the most important thing in pathfinding is the scene representation; the AI agents need to know where the obstacles are, especially static obstacles. Previously, we created our custom representation by dividing the map into a 2D grid, and then we implemented our custom pathfinding algorithm by implementing A* on that representation. Would it not be awesome if Unity could do all, that for us?
Fortunately, Unity can do this using NavMeshes. While in our 2D representation we divided the world into perfect squares, with NavMeshes, we divide the world using convex polygons. This representation has two interesting advantages: first, every polygon can be different from the other, and therefore we can use few a polygons for wide open areas and many smaller polygons for very crowded spaces; second, the agent is not locked on a grid...