Nav Mesh Generation

From PVKII Wiki
Revision as of 12:31, 4 August 2023 by Crazytalk (talk | contribs) (Created page with "=== Nav mesh generation === #'''Load a listen server for the map''' you're going to generate a mesh. #'''Kick any bots out.''' If there are any bots left it can slow down mesh generation and saving, could crash stuff etc. '''bot_quota 0''' #Enable cheats '''sv_cheats 1''' #Enable the drawing of the mesh: '''nav_edit 1''' You should now see the nav mesh loaded if there was one already and it will look like the picture below. The yellow square is the highlighted nav ar...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Nav mesh generation

  1. Load a listen server for the map you're going to generate a mesh.
  2. Kick any bots out. If there are any bots left it can slow down mesh generation and saving, could crash stuff etc. bot_quota 0
  3. Enable cheats sv_cheats 1
  4. Enable the drawing of the mesh: nav_edit 1

You should now see the nav mesh loaded if there was one already and it will look like the picture below.

The yellow square is the highlighted nav area. The stitches connecting them to the red boxes around it signify that the nav area selected is connected to the mesh the stitch connects to. This means that the bot knows that this nav area is accessible from these other nav areas. If the stitch is blue, its a one way connection from the highlighted nav area to the connected nav area. If the stitch is a whiteish green color like this that means the nav areas are bidirectionally connected.

Nav-mesh-loaded.jpg

If there isn't already a nav mesh you can generate one automatically by using nav_generate

This will try to auto generate a nav mesh and in some cases will do a very good jerb.

The auto generation is good but it won't know about water or lava or hazards. If you have hazards you should check them after generating a mesh, it will likely be covered in nav areas and the bots will be able to path to that area. Removing the nav areas from hazards won't mean bots won't end up falling into the hazard, they just won't do it like they meant to.

Lets assume for a moment the auto mesh generation got your mesh perfect and you didn't need to change a thing.

You still need to generate second order nav mesh data and you can do that by using nav_analyze.

That's it! Nothing else to do. Bots can path around your map.

Now, if the auto generated mesh isn't to your liking there are some things you can do about this.

in pvkii-dev/cfg/ there is a config file for debugging bots debug_bot.cfg. There are bindings there to manipulate the mesh and have the bots move around. I'll address some of the commands found in there.

WARNING: THERE IS NO UNDO FOR NAV MESH OPERATIONS, SAVE FREQUENTLY.

When you've made changes to the nav mesh and want to save you can use nav_save or nav_analyze

Additional nav mesh commands and information can be found here:

https://developer.valvesoftware.com/wiki/Navigation_Meshes

Some information specific to our bots and mesh problems you may encounter with GrogBots can be found below.

Narrow Walk Ways

If your bot needs to walk a narrow walkway or area, you can try to get them to do it by splitting the narrow walk way into little tiny mesh islands across the walk way. For example, here is a staircase that is fairly narrow for a bot's liking. The nav mesh is really just a place where the bot can place a waypoint for navigation, a nav mesh isn't a boundary marker for bots.

Narrow-staircase-nav-mesh.jpg

Setting these nav areas too far apart will allow the bots to stray from the center of the staircase more. If you bot is fighting on these steps, all bets are off because a bot can path directly to an enemy even if they're not within a nav area.

Bots Are Getting Stuck On Corners Or Up Against Trees/Objects

Try cutting away the nav areas that surround the object the bot gets stuck on. If its a corner and your bot is going to turn that corner, it's getting stuck because bots will not follow their nav path directly and they're trying to cut corners... yeah... I said it.

You can use nav_split to subdivide the nav area around the object and nav_delete while your cursor is over the mesh you want to remove.

If its a narrow area like a space between two trees or a signpost and a wall, the auto generation may have put a mesh between those objects or connected to areas. Again, try to cut away the nav area around the trouble spot.