Category:Navmesh

From the CreationKit Wiki
Revision as of 19:10, 13 August 2012 by imported>Cipscis (Reverted edits by Heecf (talk) to last revision by JohnnyWing)
Jump to navigation Jump to search
A typical interior cell navmesh

Navmeshes

Navmeshes represent the actual area that Actors can walk on. A Navmesh consists of a list of triangles (composed of verts and edges), derived data such as slope, and additional information like cover, preferred paths, and water areas. Navmeshes allows the AI to build better and more efficient paths based on data added to the Navmesh in the Editor or generated dynamically at runtime.

For a basic introduction to creating Navmesh, see the Navmesh Tutorial. You should also familiarize yourself with the Navmesh Toolbar and Controls.

Creating Navmesh

Hand-Built vs Generated Navmeshes

In the Creation Kit, you can choose to construct a Navmesh by hand or automatically generate it. During your initial work on a space, a quick Recast-Generated Navmesh may be all you need for testing purposes. But automated generation will never produce the kind of clean, coherent Navmesh required for a level to perform well. Some amount of hand cleanup will always be required.

There are pros and cons to each approach:

  • Building your Navmesh by hand usually produces the best and cleanest results. However, this can be time-consuming, especially until you become comfortable with the Navmesh controls.
  • Generating a Navmesh, then cleaning it up, gives you a functional Navmesh quickly. For simple kit-based spaces, it's fairly easy to generate a good Navmesh early in the development process, then clean it up as you continue to develop and clutter the space. On the other hand, in complex, cluttered, or organic spaces, Navmesh Generation will often produce unusable results, and cleaning up a badly-generated Navmesh may be more time-consuming than building it by hand.

Navmeshing Exteriors

When working in the exterior (or a Worldspace):

  • Remember that each Cell has distinct Navmesh(es). Navmesh verts cannot be moved outside of their initial cell.
  • Make sure to Finalize your Navmesh. In order for exterior Navmeshes to finalize correctly, the verts on the borders of each cell must be aligned with corresponding verts in the adjacent cell. A green edge indicates that a connection has been made.
  • Toggle cell borders by pressing [B]. The borders will be represented by dashed yellow lines on the terrain.
  • Toggle Navmesh in surrounding cells by pressing [N]. Turning the surrounding Navmeshes off will increase performance and make it easier to work in the border regions, but make sure to turn them back on so you can align the border verts.
  • You can also increase performance by reducing the number of Grids to Load under File -> Preferences -> Misc.
  • When moving around in Navmesh Mode, it often takes a long time for cells to load. Press [F5] to force a reload.

Navmesh Data

Cover

Information about walls and cover points is encoded in the Navmesh to improve AI performance, especially in ranged combat. To add Cover data to your Navmesh, select Find Cover Edges from the Navmesh Toolbar or Navmesh Menu.

Water

Water Triangles (Blue) allow you to indicate an area of deep water. Some creatures will behave differently while in or around water.

Note that, in areas of deep water, the Navmesh should always be placed on the ground surface (underwater) instead of on top of the water plane.

To mark/unmark a triangle as Water, select the triangle(s) and press the "O" hotkey.

Preferred Pathing

Preferred Paths (Gold) have a lower 'cost' when evaluated by the AI, meaning that Actors will generally try to use those triangles instead of non-Preferred triangles. For example, triangles that lie on major roads are often marked as Preferred Paths to encourage Actors to follow them rather than taking a more direct off-road path.

To mark/unmark a triangle as Preferred, select the triangle(s) and press the "P" hotkey.

Note that triangles can be marked as both Water and Preferred. Such a triangle will be marked with a teal color.

Dropdowns

Dropdown Edges (Pink) indicate a connection between two edges that allows an Actor to jump down from a higher ledge to a lower one. The AI will not evaluate the jump distance or other obstacles, so they may take damage or become stuck after the fall if the Navmesh is not positioned carefully.

Drop-down edges are taken into consideration when using navmesh Pathing Tests.

To mark edges as dropdowns, select the top and bottom edges (in any order) and press "P".

This operation can only be performed on a per-case basis. For example: if you wish to mark a series of ten upper/lower edges as drop-down, you'll need to select each pair, press "P", and repeat on the next pair.

Note that finalizing a Navmesh will remove any dropdowns from the Navmesh, so you will need to recreate them.

Navmesh Cleanup

Finding Errors

When you save a new or modified Navmesh, you may get an error message about it. To fix Navmesh errors:

  • Go to the cell the Navmesh is in and press [Ctrl+F] to search the Navmesh for errors.
    • Note that this will only check the current Navmesh. If your cell has multiple Navmeshes, you will need to search each of them individually.
    • If you are Navmeshing a large area, it may be useful to search for errors as you work.


For a more detailed walkthrough about how to fix errors in a Navmesh, see the Tutorial.

Finalizing Navmesh

Finalizing Navmesh is generally the last thing done on a cell. If you edit a Navmesh, you should be sure to finalize it afterwards.

  • After Finalizing Interiors and Exteriors, check each door to make sure that it has a green triangle nearby. When an Actor stands on that triangle, they can use the door. If no green triangle exists near a door, the AI will not be able to use the door.
  • In Exteriors, Navmeshes must remain in their own cell. The Finalization process is used to connect the Navmeshes for each cell together at their borders.
    • Make sure the edges of one exterior cell's Navmesh line up properly with those of the adjacent cells.
    • Pressing "W" until in "Navmesh Only" view mode is helpful
    • Pressing "N" if in single-cell Navmesh view mode will return to multi-cell view mode.
    • Make sure that the border verts of the two Navmeshes line up in every way possible, including height.
    • After finalizing, the Navmeshes should have thick green lines on their borders if properly linked together. If thick green lines do not appear on an edge where you expected them to, adjust the verts and edges and Finalize again.
    • If you don't have thick green lines between adjacent exterior Navmeshes, Actors cannot path from one cell to the other. This is very bad, and will cause AI to behave poorly.