Building a navmesh in Reality Composer Pro
Configure a navigation mesh in Reality Composer Pro to define walkable areas and paths for AI-controlled entities in your scene.
Overview
A Reality Composer Pro navmesh provides a representation of a scene’s navigable surfaces, simplifying pathfinding for AI-driven NPCs (non-player characters) in complex 3D environments.
Create a navigation named layers file
To create and use navigation layers, areas, and flags, create a Navigation Named Layers file to store the mappings of the indexes to names. In your Navigation Mesh and Navigation components, you can reference these entries by name. When you export to a reality file, the indexes match the structs in Swift code, enabling you to reference them in code.
In the Project Browser, Control-click to create a new file, then select Navigation Named Layers.
Expand the drop-downs for Layers, Areas, and Flags to add or remove entries and rename them.
Create a navmesh
In the Scene Hierarchy, Control-click a scene entity (World, for example), then click Add Component > Navigation Mesh. In the Inspector, under Navigation Mesh Component, click [+] to add a new Navigation Mesh. Add a Navigation Named Layers file to your Navigation Mesh Component. The Navigation Mesh Component dropdowns for Layers, Areas, and Flags will be populated with the entries from the Named Layers File. Add a Layer to identify your mesh. Entities in the scene reference this layer to access the map of available paths. For more information about adding a layer, see doc:NavigationMeshLayers.
Configure the properties for each of the following sections, described later in this article:
Shapes
Off Mesh Connections
Generation Parameters
Tags
Click Generate Navigation Mesh when you’re ready.
[Image]
Define navigation mesh shapes
The shape setting controls the area of the scene the generated mesh covers. By default, the shape encompasses the entire scene. To generate the mesh for only part of the scene, drag the bounding box to the desired area.
Shape selection only includes entities at or below the current hierarchy level. For example, in the following hierarchy:
World
- Entity 1
- Entity 2
- Entity 3If you place the navigation mesh component on Entity 2, it selects only Entity 2 and Entity 3.
If you place it on World, it selects everything.
Add off-mesh connections
Off-mesh connections let you link points on the mesh that normal geometry does not connect. For example, use an off-mesh connection to create a connection between two points that only certain entities can traverse outside the standard mesh connections.
Click [+] to add an off-mesh connection, then use the Move tool to position the connection.
You can create as many off-mesh connections as you want.
You can give off-mesh connections unique names, which other components and graphs can reference — such as triggering a specific animation when an entity moves along the off-mesh connection.
Control navigation mesh generation with parameters
These parameters give you more granular control over how Reality Composer Pro generates the navigation mesh. For example, to support larger characters increase Character Radius; to prevent the mesh from covering steep terrain, reduce Walkable Slope Angle.
Basic
- Cell Size
The cell size (in world units) to use when sampling the source geometry.
- Cell Height
The cell height (in world units) to use when sampling the source geometry.
- Character Height
The minimum floor-to-ceiling height for the floor to be considered walkable.
- Walkable Climb Height
Maximum ledge height that is considered walkable.
- Walkable Slope Angle
Maximum slope that is considered walkable.
- Character Radius
Distance to erode or shrink the walkable area of the height field away from obstructions. Use this to prevent larger characters from traversing parts of the mesh.
Advanced
- Max Edge Length
Max length for contour edges on the border of a mesh.
- Max Simplification Error
The maximum distance that a simplified contour’s border edges can deviate from the original raw contour.
- Min Cells per Region
Minimum number of cells allowed to make isolated island areas.
- Min Cells to Merge Regions
Regions with a span count smaller than this value merge with larger regions when possible.
- Detail Sample Distance
Sampling distance to use when sampling the detail mesh.
- Detail Sample Max Error
The maximum distance the detail mesh surface can deviate from heightfield data.
- Max Vertices per Polygon
Max vertices per polygon in the final created navigation mesh.
- Partition Method
The algorithm used to partition the height field into regions. Options: Watershed, Monotone, or Layer.
Watershed (default) — Produces the best meshes.
Monotone — Produces the fastest meshes.
Layer — Fast and handles open regions better than Monotone.
Use navigation mesh tags to define how entities move
You can use tags to control how entities traverse parts of the mesh — for example, you can use tags to prevent certain entities from traversing areas with specific tags. There are two main types of tags:
Area — A tag that assigns an area type to a region, which entities can use when computing navigation paths. Areas can be used to assign a cost to an area.
Flag — A binary tag that entities can use to selectively include or exclude areas when navigating.
Use a **Navigation Component **to to assign the costs for an entity to path through an area and which flags to include or ignore.
Add a navigation mesh tag
Click [+] to add one or more tags to areas of the Navigation Mesh, then use the Move tool to position the selection area over the area you want to tag. For more information about adding Area and Flag tags, see doc:NavigationMeshLayers.
Use the Position, Height, and Radius settings to change the position and size of the tagged area.
You can have as many tags as you want in a region.