Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.Close
For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.Close
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.