Navigation and Pathfinding

In many games, a character needs to be able to travel automatically from its current position to a desired destination. For example, you might control a player character by clicking on a target point in the game world, or perhaps an NPC enemy might need to find a route to intercept the player. In some cases, this will be a simple matter of moving in a straight line or along a preset path but there are also game worlds based around buildings, forests or other settings where the route to the target is not so direct. In games like these, some control logic is needed to allow the character to make decisions at each point along its journey to choose its next step. The process of choosing a character's movements around the game world like this is known as navigation.

There are various techniques that can be used to navigate a character to its destination, some of which involve an element of trial and error with mistakes and wrong turnings. Often though, the desired behaviour is to make the character appear to be planning its path intelligently, taking the most direct or advantageous route. This requires a bit of artificial intelligence (AI) to establish the best way to get from the starting point to the destination. This task in game AI is known as pathfinding and although it can be quite technical, Unity makes some common cases very easy using its built-in pathfinding system. This section describes Unity's navigation and pathfinding in detail.

Page last updated: 2013-10-04