Class RecastGraph Extends NavmeshBase, IUpdatableGraph
Automatically generates navmesh graphs based on world geometry.
The recast graph is based on Recast (http://code.google.com/p/recastnavigation/).
I have translated a good portion of it to C# to run it natively in Unity.
For a tutorial on how to configure a recast graph, take a look at Automatically generating a navmesh.
Inspector
Shape
Whether to use 3D or 2D mode.
Center of the bounding box.
Size of the bounding box.
Rotation of the graph in degrees.
Input Filtering
Determines how the initial filtering of objects is done.
Objects in all of these layers will be rasterized.
Objects tagged with any of these tags will be rasterized.
Use terrains to calculate the navmesh.
Rasterize tree colliders on terrains.
Controls how much to downsample the terrain's heightmap before generating the input mesh used for rasterization.
Use scene meshes to calculate the navmesh.
Use colliders to calculate the navmesh.
Agent Characteristics
Radius of the agent which will traverse the navmesh.
Character height.
Height the character can climb.
Max slope in degrees the character can traverse.
List of rules that modify the graph based on the layer of the rasterized object.
Rasterization
Voxel sample size (x,z).
If true, divide the graph into tiles, otherwise use a single tile covering the whole graph.
Size in voxels of a single tile.
Longer edges will be subdivided.
Max distance from simplified edge to real edge.
Minumum region size.
Controls detail on rasterization of sphere and capsule colliders.
Runtime Settings
Advanced
Require every region to have a RelevantGraphSurface component inside it.
Default penalty to apply to all nodes.
How a recast graph works
When generating a recast graph what happens is that the world is voxelized. You can think of this as constructing an approximation of the world out of lots of boxes. If you have played Minecraft it looks very similar (but with smaller boxes).
The Recast process is described as follows:
The voxel mold is build from the input triangle mesh by rasterizing the triangles into a multi-layer heightfield. Some simple filters are then applied to the mold to prune out locations where the character would not be able to move.
The walkable areas described by the mold are divided into simple overlayed 2D regions. The resulting regions have only one non-overlapping contour, which simplifies the final step of the process tremendously.
The navigation polygons are peeled off from the regions by first tracing the boundaries and then simplifying them. The resulting polygons are finally converted to triangles which makes them perfect for pathfinding and spatial reasoning about the level.
The recast generation process usually works directly on the visiable geometry in the world. This is usually a good thing, because world geometry is usually more detailed than the colliders. You can, however, specify that colliders should be rasterized instead. If you have very detailed world geometry, this can speed up scanning and updating the graph.
Exporting for manual editing
In the editor there is a button for exporting the generated graph to a .obj file. Usually the generation process is good enough for the game directly, but in some cases you might want to edit some minor details. So you can export the graph to a .obj file, open it in your favourite 3D application, edit it, and export it to a mesh which Unity can import. You can then use that mesh in a navmesh graph.
Since many 3D modelling programs use different axis systems (unity uses X=right, Y=up, Z=forward), it can be a bit tricky to get the rotation and scaling right. For blender for example, what you have to do is to first import the mesh using the .obj importer. Don't change anything related to axes in the settings. Then select the mesh, open the transform tab (usually the thin toolbar to the right of the 3D view) and set Scale -> Z to -1. If you transform it using the S (scale) hotkey, it seems to set both Z and Y to -1 for some reason. Then make the edits you need and export it as an .obj file to somewhere in the Unity project. But this time, edit the setting named "Forward" to "Z forward" (not -Z as it is per default).
This is an A* Pathfinding Project Pro feature only. This function/class/variable might not exist in the Free version of the A* Pathfinding Project or the functionality might be limited.
The Pro version can be bought here
Inner Types
Public Methods
Changes the bounds of the graph to precisely encapsulate all objects in the scene.
Moves the recast graph by a number of tiles, discarding old tiles and scanning new ones.
Public Variables
Maximum (vertical) distance between the sides of two nodes for them to be connected across a tile edge.
Determines how normals are calculated.
Size of a tile in world units along the X axis.
Size of a tile in world units along the Z axis.
Whether the base of the graph should default to being walkable or unwalkable.
World bounding box for the graph.
Voxel sample size (x,z).
Radius of the agent which will traverse the navmesh.
Determines which objects are used to build the graph, when it is scanned.
Max distance from simplified edge to real edge.
Whether to use 3D or 2D mode.
Size in voxels of a single tile.
Center of the bounding box.
Longer edges will be subdivided.
Max slope in degrees the character can traverse.
Internal field used to warn users when the mesh includes meshes that are not readable at runtime.
Minumum region size.
List of rules that modify the graph based on the layer of the rasterized object.
Require every region to have a RelevantGraphSurface component inside it.
Rotation of the graph in degrees.
If true, scanning the graph will yield a completely empty graph.
Size of a tile along the X axis in voxels.
Size of a tile along the Z axis in voxels.
If true, divide the graph into tiles, otherwise use a single tile covering the whole graph.
Height the character can climb.
Character height.
Public Enums
Whether the base of the graph should default to being walkable or unwalkable.
Whether to use 3D or 2D mode.
Inherited Public Members
Returns an XZ bounds object with the bounds of a group of tiles in graph space.
Returns a rect containing the indices of all tiles touching the specified bounds.
Returns a rect containing the indices of all tiles touching the specified bounds.
Lower bound on the squared distance from the given point to the closest node in this graph.
Called when tiles have been completely recalculated.
Replace tile at index with nodes created from specified navmesh.
World bounding box for the graph.
Enable to draw gizmos in the Unity scene view.
Should navmesh cuts affect this graph.
Size of the bounding box.
Index of the graph, used for identification purposes.
Used as an ID of the graph, considered to be unique.
Used in the editor to check if the info screen is open.
Default penalty to apply to all nodes.
True if the graph has been scanned and contains nodes.
Name of the graph.
Handles navmesh cutting.
Is the graph open in the editor.
True if the graph will be included when serializing graph data.
True if the graph should be visible in the editor.
Show an outline of the polygons in the Unity Editor.
Show the surface of the navmesh.
Show the connections between the polygons in the Unity Editor.
Number of tiles along the X-axis.
Number of tiles along the Z-axis.
Determines how the graph transforms graph space to world space.
Private/Protected Members
Throws an exception if it is not safe to update internal graph data right now.
Convert character radius to a number of voxels.
Generate connections between the two tiles.
Number of extra voxels on each side of a tile to ensure accurate navmeshes near the tile border.
True if the graph exists, false if it has been destroyed.
All tiles.
Deprecated Members
Controls detail on rasterization of sphere and capsule colliders.
Layer mask which filters which objects to include.
Use colliders to calculate the navmesh.
Use scene meshes to calculate the navmesh.
Use terrains to calculate the navmesh.
Rasterize tree colliders on terrains.
Objects tagged with any of these tags will be rasterized.
Controls how large the sample size for the terrain is.