Tagging with Custom Data

You can tag arbitrary areas of your NavData with custom data called NavTags, which you can use to influence the way your characters plan and follow paths in the area at runtime. For example:

For example, the following image shows a terrain set up with several different types of NavTags:

NavTag data format

Each NavTag contains:

NavTags may be represented by either:

Embedding NavTags at generation time

There are multiple possible approaches to embedding NavTags into the static NavData that you pre-generate for your terrains.

Tagging individual triangles

Each time your GeneratorInputProducer class provides a triangle to the NavData generation system, it can tag that triangle with a particular type of NavTag.

  • Call either the ClientInputConsumer::ConsumeTriangleFromPos() or ClientInputConsumer::ConsumeTriangleFromPosInClientCoordinates() method, and pass your NavTag as a parameter.

Providing TagVolumes

Your GeneratorInputProducer class can specify volumes that define which NavTags should be applied automatically to all triangles that intersect the volumes. To use this approach:

  1. Create an instance of the ClientInputTagVolume class.
  2. Set up the instance with its contour, altitude, and NavTag data in a call to ClientInputTagVolume::Init().
  3. Provide your volume in a call to ClientInputConsumer::ConsumeTagVolume().

Adding NavTags dynamically at runtime

You can add NavTags dynamically at runtime either by spawning TagVolumes and assigning them to your Databases, or by using the dynamic BoxObstacle and CylinderObstacle classes provided by the dynamic obstacle management system. The NavMesh in the area of the new TagVolume or the obstacle is automatically re-generated and re-triangulated to reflect your custom NavTag.

For details, see Using Dynamic Obstacles and TagVolumes.

NavTag color

You can choose a color for rendering the triangles and TagVolume based on their NavTag. The colors help in identifying NavTags quickly.

You can set the DynamicNavTag color using these functions:

If you set a NavTag as exclusive, its color is automatically set to red as shown in the following figure.

NOTE:The method to specify a NavTag for a generation TagVolume or runtime TagVolume has changed as shown in these figures. The NavTag display in the panels has also changed for supporting the NavTag color.

Additionally, the default color for a runtime TagVolume is dark orange as shown in the following figure.

Following parameters for NavTag color are added in the GeneratorAdvancedParamaters class:

These colors are automatically set for the NavTag during the generation time. The m_emptyDefaultNavTagColor parameter or m_nonEmptyDefaultNavTagColor parameter is set for the default NavTag depending on whether it is empty. This applies to all the triangles by default.

The m_nonDefaultNavTagColor parameter is set for the NavTag in the following cases:

The m_nonDefaultNavTagColor parameter is not set if you change the color of the NavTag before adding the triangle or TagVolume.

You can modify these colors in the Advanced Parameters panel of the Navigation Lab. See the following figure:

The following methods are added in the DynamicNavTag class:

Tagging NavGraphs

If you use NavGraphs in your terrain, you can tag their vertices and edges with NavTags too.

  1. After you create the NavGraphBlobBuilder that you will use to set up the NavGraph, pass an instance of each type of NavTag that you want to add to any vertex or edge in the NavGraph in sequential calls to NavGraphBlobBuilder::AddNavTag(). Each type of NavTag is identified by an index that is returned by the method.
  2. Each time you add a vertex or edge, use the NavGraphBlobBuilder::AddVertexWithNavTag(), NavGraphBlobBuilder::AddBidirectionalEdgeWithNavTag() or NavGraphBlobBuilder::AddMonodirectionalEdgeWithNavTag() methods, and pass the index that corresponds to the type of NavTag you want that vertex or edge to be tagged with.

See also Creating NavGraphs.

Handling merging and conflicts

When two or more areas tagged with different NavTags overlap, the NavTags are not merged. Instead, the NavTag that is determined to be lower by calling the < operator of the NavTag class is kept.

For example, in the following image, the exclusive volume is lower than the orange volume, which is lower than the green volume, which is lower than the light blue volume.

See the implementation in the navtag.h file for details.