Navigation Meshes and Agents
Unity provides navigation meshes (NavMeshes) and artificial intelligence (AI) agents that can plan pathways and move objects along those calculated paths. Pathfinding is a classic AI task, and Unity has provided game developers with fast and efficient pathfinding components that work out of the box.
Having objects that can automatically plot and follow paths from their current location to the desired destination point (or reoriented to a moving target object) provides the components for many different kinds of interactive game characters and mechanics. For example, we can create point-and-click games by clicking on a location or object toward which we wish one or more characters to travel. Or, we can have enemies that “wake up” when our player’s character is nearby and move toward (seek) our player, then perhaps go into combat or dialogue mode once they are within a short distance of our player’s character.
This chapter...