Recast graph on a terrain
Example scene with a terrain and a recast graph.
This example scene demonstrates how to use a recast graph on a Unity terrain.
In the scene, you can move the cursor around, and the agent will move to that position.
Graph setup
The recast graph works pretty much out of the box on Unity terrains. The only thing you need to ensure is that the graph has the RecastGraph.rasterizeTerrain option enabled.
The recast graph converts the terrain into a mesh before rasterizing it. To improve performance when rasterizing the terrain, the heightmap is downsampled. You can adjust how much the recast graph should downsample the heightmap using the RecastGraph.terrainSampleSize field. Lower values will result in a more accurate graph. Using higher values can speed up scanning a bit, and is of particular importance if you want to do graph updates at runtime.
Any trees on the terrain will be automatically detected and added to the graph. However, only colliders will be rasterized on trees. Rasterizing the meshes in tree prefabs is not supported. This is usually what you want since rasterizing all meshes on all trees can very quickly make the scan take a very long time. Colliders on trees will be rasterized regardless of what the RecastGraph.rasterizeColliders field is set to.