Class RecastNavmeshModifier Extends VersionedMonoBehaviour, RecastMeshObj

Public

Overrides navmesh generation settings for a single mesh or collider.

Sometimes you want to tweak the RecastGraph on a per-object basis. For example you might want to make some objects completely unwalkable, or you might want to special case some objects to remove them from the navmesh altogether.

You can do this using the RecastNavmeshModifier component. Attach it to any object you want to modify and configure the settings as you wish.

Using the RecastNavmeshModifier component you can:

  • Exclude an object from the graph's scan completely.

  • Ensure an object is included in the scan, even if it would normally be excluded.

  • Make the surfaces of an object unwalkable.

  • Make the surfaces of an object walkable (this is just the default behavior).

  • Create seams in the navmesh between adjacent objects.

  • Mark the surfaces of an object with a specific tag (see Working with tags).

Adding this component to an object will make sure it is included in any recast graphs. It will be included even if the Rasterize Meshes toggle is set to false.

If you are using the Rasterize Meshes option on the recast graph, and you are updating the graph during runtime, then disabling it and attaching RecastNavmeshModifiers (with dynamic set to false) to the objects you want to rasterize can be good for performance. This is because it's not possible to find meshes in the scene efficiently in Unity, so every time even a small part of the graph is updated, it has to search all meshes in the scene for ones to rasterize. This can be slow if you have a lot of meshes in the scene. RecastNavmeshModifiers are stored in a tree for extremely fast lookup (O(log n + k) compared to O(n) where n is the number of meshes in your scene and k is the number of meshes which should be rasterized, if you know Big-O notation. But as always, profile before you optimize.

Note

If dynamic is false, then the object is not allowed to move. If it does, the internal lookup tree will be incorrect and the graph may not be updated correctly.

See

You can also do similar changes on a per-layer basis using RecastGraph.perLayerModifications.

Public Methods

ResolveMeshSource (meshFilter, collider, collider2D)

Resolves the geometry source that is to be used.

Public Static Methods

GetAllInBounds (buffer, bounds)

Fills the buffer with all RecastNavmeshModifiers which intersect the specified bounds.

Public Variables

dynamic

Enable if the object will move during runtime.

Public
geometrySource

Source of geometry when voxelizing this object.

Public
includeInScan

Determines if the object should be included in scans or not.

Public
mode

Surface rasterization mode.

Public
solid

If true then the mesh will be treated as solid and its interior will be unwalkable.

Public
surfaceID

Voxel area for mesh.

Public

Public Enums

GeometrySource

Source of geometry when voxelizing this object.

Public
Mode
Public
ScanInclusion
Public

Private/Protected Members

Awake ()

Calculates and returns the bounding box containing all geometry to be rasterized.

OnUpdate (components, _)
OnUpgradeSerializedData (migrations, unityThread)

Reset ()

Handle serialization backwards compatibility.

UpgradeSerializedData (isUnityThread)
dynamic
Private
geometrySource
Private
includeInScan
Private
mode
Private
solid
Private
surfaceID
Private
tree

Components are stored in a tree for fast lookups.

Protected Static
treeKey
Private

Deprecated Members

area

Voxel area for mesh.

Public