Navmesh Documentation

From Nexus Mods Wiki
Revision as of 15:18, 25 October 2019 by WarhorseStudios (talk | contribs) (Created page with "<div class="row"><div class="col-xs-12" id="xwikicontent"> Navmesh is extremely important for game. It defines where an NPC can go and how will it get there. It can only move...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Navmesh is extremely important for game. It defines where an NPC can go and how will it get there. It can only move on navmesh so any hole will become an impassable obstacle.

Navmesh debug

Button approach

1. Put 3DDebug pannel onto your toolbar.

Ledges Documentation Image6.png

2. Hit the first button to show navmesh and generate it in your vicinity.

Navmesh Documentation image2.png


3. Hit the second button to hide navmesh.

Manual approach

You can visualize the navmesh to check if it's alright. You can choose from two options.

Variant 1:

  1. Make sure layer "_test_nav_area" is loaded.
  2. Find a tag point named RecastDebugLocator and move it to the position you want to debug.
  3. Use wh_ai_RebuildDebugTile x command where x is a grid size around the navmesh tile that contains RecastDebugLocator.
    • 0 = only that tile
    • 1 = that and neighbouring tiles (9 in total)
    • 2 = 25 tiles
    • ... 
  4. Visualise the navmesh by pressing NavMesh button in 3DArt utitlity panel.

Variant 2:

1. Make sure layer "_test_nav_area" is not loaded (if it is be it will take a looooooong time to generate the navmesh)

2. In case you don't have navmesh from packs you need to build it first:

  • Check if you have a navigation area encompassing the area you want to debug. If not go to AI/NavigationArea and create it so everything is in (Z-axis matter in this case, you have to intersect the terrain and have it high enough so all the surfaces you want navmesh on are within its volume). Make sure MediumSizedCharacter is checked.
  • Navmesh Documentation image3.png
  • Navmesh Documentation image4.png
  • Hit menu AI/Request a full MNM rebuild. The navmesh will be build in all the navigation areas that are currently loaded. This may take a long time so better make sure you have only those you want to check.

3. If you right-click any empty space on Toolbar you'll be able to turn on 3DArt utility panel. There's a Navmesh button on it that will display the nevmesh.

Navmesh Documentation image5.png

4. In case it's poorly visible because of it being partialy under the terrain, you can offset it with Zoffset button on the panel.

For in depth information you can visit AI part of the navmesh wiki here

Rules for navmesh generation

The navmesh will be generated only if some conditions are met, of course. We can't have NPCs running through walls and stuff. 

  • Width – if the space is at least wide enough for a character's capsule. That should be about 70 cm, but please don't do the bare minimum. The more space NPCs have the less likely they are to get stuck.
  • Height – if the vertical space is at least 200 cm. This gives enough room for their helmets with feathers emoticon_wink.png This problem can occur specificaly under the door frames, horizontal beams etc.
  • Slope – the slope cannot be steeper than 60 degrees.
  • Step –  step cannot be higher than 25 cm.

Be aware that navmesh is only generated from the physics.

Common problems and troubleshooting


Navmesh Documentation image6.png

The little fence here is creating a high step and thus blocking the navmesh generation. For the player however this is no obstacle, he would be able to jump over it easily and get inside to the small garden. But NPCs wouldn't be able to get to him.

Navmesh Documentation image7.png

Easiest solution here is to get rid of the little fence completely. Notice how the navmesh of the garden is now connected to the navmesh of the surroundings.

Ceiling Height

Navmesh Documentation image8.png

The 1st floor is too close to the ground so the navmesh leading to inside won't be generated.

Navmesh Documentation image9.png

Solution is to move the whole structure up a bit.

Terrain height mismatch

The navmesh is generated in simplified polygons, which can cause some troubles. If the steepness of a small hill or depression is not enough to disrupt the navmesh, it can create local maximul (respective minimum) which is too far from navmesh. This happens only in the middle of navmesh tiles but it can cause troubles during combat, teleportation, LOD movement, save/load, etc. We created a test that checks for these places and allows the terrain to be altered so the navmesh generates correctly. To run the test use command:

wh_ai_NavmeshHeightTest 1

This command checks the whole navmesh and draws red cylinder for each invalid place. It takes around 40 s on whole Rataje level to execute it, for which the game is frozen. Different aruments are:

  • 0 – clears the generated results
  • 2 – runs the test and prints the list of invalid coordinates into log

The debug draw itself can be controlled without the need of re-running the test. Use cvar wh_ai_NavmeshHeightTestDebugDraw with argument:

  • 1 – draws red cylinders (easy location of spots from distance)
  • 2 – draws blue spheres at points where navmesh is (for height check)
  • 3 – draws both

Example of a problematic depression:

 Navmesh Documentation image10.PNG

Navmesh Documentation image11.PNG

Or hill:

Navmesh Documentation image12.PNG


The test discovered few other issues, although it doesn't find all of their occurances, since it was not designed for it.

Sometimes vegetation cone is too flat that it is walkable and navmesh gets generated on top of it. The test finds some of these cases, which need to be fixed, since we don't want walkable bushes (nor by player neither by NPC):

 Navmesh Documentation image13.PNG

Navmesh Documentation image14.PNG


It can also find invisible floor in mines which looks weird, when someone is standing on top of it:

 Navmesh Documentation image15.PNG

Navmesh Documentation image16.PNG