Unity Artificial Intelligence Programming - Fourth Edition
by Dr. Davide Aversa, Aung Sithu Kyaw, Clifford Peters
Navigation Mesh
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access