Calculating our scene’s NavMesh
Pathfinding algorithms rely on simplified versions of the scene. Analyzing the full geometry of a complex scene is almost impossible to do in real time. There are several ways to represent Pathfinding information extracted from a scene, such as graphs and NavMesh geometries. Unity uses the latter – a simplified mesh similar to a 3D model that spans all areas that Unity determines are walkable. In the next screenshot, you can find an example of NavMesh
generated in a scene – that is, the light blue geometry:
Figure 9.54: NavMesh of walkable areas in the scene
Generating NavMesh
can take from seconds to minutes depending on the size of the scene. That’s why Unity’s Pathfinding system calculates the NavMesh
once in the Editor, so when we distribute our game, the user will use the pre-generated NavMesh
. In previous Unity versions, like lightmapping, NavMesh
used to be baked into a file for later use. That...