Difference between revisions of "Navigation Meshes"

From Valve Developer Community
Jump to: navigation, search
(Lining up Tricky Jumps and Narrow Doorways)
m (Cleared a dead link.)
 
(67 intermediate revisions by 29 users not shown)
Line 1: Line 1:
[[Category:Level Design]]
+
{{otherlang2
=Introduction=
+
|jp=Bot_Navigation_for_Counter-Strike:Source:jp
A ''Navigation Mesh'' represents the "walkable areas" of a map. This data is '''required''' by [[bot|Bots]] and Hostages in Counter-Strike:Source, allowing them to "know" how to move around in the environment.
+
}}
 +
A '''Navigation Mesh''' represents the "walkable areas" of a map. This data is '''required''' by [[bot|Bots]] and Hostages in [[Counter-Strike: Source]] and [[Counter-Strike: Global Offensive]], and all [[NextBot]] entities in [[Left 4 Dead]], [[Left 4 Dead 2]] and [[Team Fortress 2]], allowing them to "know" how to move around in the environment.
 +
 
 +
Navigation Mesh data is stored in a [[NAV]] file corresponding to the map file (.bsp) for which it is used.  For example, the nav mesh for <code>cstrike\maps\de_dust.bsp</code> is stored in <code>cstrike\maps\de_dust.nav</code>.
 +
 
 +
= Automatic navigation mesh generation =
 +
To support the many community-created maps, CS:S and CS:GO include an automatic mesh generation system.  The first time you attempt to play a custom map with bots, the generation system will build a <code>.nav</code> file for that map.  Depending on the size and complexity of the map, this may take a few minutes to a few hours.  Most maps take about 5 minutes to auto-generate a .nav file.  Once the generation is complete, a .nav file is saved to your hard drive for future use.
  
Navigation Mesh data is stored in a ''.nav'' file corresponding to the map file (.bsp) for which it is usedFor example, the nav mesh for <code>cstrike\maps\de_dust.bsp</code> is stored in <code>cstrike\maps\de_dust.nav</code>.
+
For games that don't support automatic mesh generation, a navigation mesh can still be generated by a game client using the console's map command to load a map, then using sv_cheats 1, followed by nav_generateYou can then upload the created .nav file to your server.
  
=Automatic Navigation Mesh Generation=
+
It is recommended that map creators create navigation meshes before releasing their map to the public.
To support the many community-created maps, Counter-Strike:Source includes an automatic mesh generation system.  The first time you attempt to play a custom map with bots, the generation system will build a .nav file for that map.  Depending on the size and complexity of the map, this may take a few minutes to a few hours.  Most maps take about 5 minutes to auto-generate a .nav file.  Once the generation is complete, a .nav file is saved to your hard drive for future use.
 
  
==What is Computed During Generation==
+
== What is computed during generation ==
 
The following steps occur during Navigation Mesh generation:
 
The following steps occur during Navigation Mesh generation:
 
* Starting at a player spawn point, walkable space is sampled by "flood-filling" outwards from that spot, searching for adjacent walkable points
 
* Starting at a player spawn point, walkable space is sampled by "flood-filling" outwards from that spot, searching for adjacent walkable points
Line 16: Line 21:
 
* Initial Encounter areas are computed
 
* Initial Encounter areas are computed
  
==Manually Starting the Generation Process==
+
== Manually starting the generation process ==
 
To start the generation process manually, type <code>nav_generate</code> from the console.
 
To start the generation process manually, type <code>nav_generate</code> from the console.
  
==Viewing the Navigation Mesh==
+
== Viewing the navigation mesh ==
To see the resulting Navigation Mesh, type <code>nav_edit 1</code>.  To turn the mesh editor off, type <code>nav_edit 0</code>.
+
To see the resulting Navigation Mesh, type <code>nav_edit 1</code>.  To turn the mesh editor off, type <code>nav_edit 0</code>. You will need to have <code>sv_cheats 1</code> to be able to view the navigation mesh.
  
==Explicitly Marking Walkable Areas (ie: "There's no mesh upstairs")==
+
== Explicitly marking walkable areas (i.e: "There's no mesh upstairs") ==
 
Some maps that have very steep stairs, ramps, or hills may confuse the generation system, resulting in the Navigation Mesh not covering the entire map.  To solve this, you can manually place additional ''walkable markers'' that tell the generator to search outwards from that point during its sampling phase.
 
Some maps that have very steep stairs, ramps, or hills may confuse the generation system, resulting in the Navigation Mesh not covering the entire map.  To solve this, you can manually place additional ''walkable markers'' that tell the generator to search outwards from that point during its sampling phase.
  
 
To add one or more walkable markers, first aim your view towards a known walkable spot in your map, then type <code>nav_mark_walkable</code> in the console.  When you are finished placing markers, type <code>nav_generate</code> to re-generate the mesh.
 
To add one or more walkable markers, first aim your view towards a known walkable spot in your map, then type <code>nav_mark_walkable</code> in the console.  When you are finished placing markers, type <code>nav_generate</code> to re-generate the mesh.
  
==Quickly Generating Meshes for Testing==
+
You can remove all previously placed walkable markers using the <code>nav_clear_walkable_marks</code> command.
 +
 
 +
== Quickly generating meshes for testing==
 
The analysis phase of the generator can be quite time consuming.  To skip it, type <code>nav_quicksave 1</code> in the console.   
 
The analysis phase of the generator can be quite time consuming.  To skip it, type <code>nav_quicksave 1</code> in the console.   
<blockquote>'''NOTE:''' "Quicksaving" skips the analysis phase, and the resultant nav mesh will be missing important data required by the CS Bots and Hostages higher-level planning and attention systems.  While useful for testing, editing, and tuning a nav mesh, be sure to do a full analyze (ie: with <code>nav_quicksave 0</code>) before publishing your nav file to others.</blockquote>
+
:{{note|"Quicksaving" skips the analysis phase, and the resultant nav mesh will be missing important data required by the CS Bots and Hostages higher-level planning and attention systems.  While useful for testing, editing, and tuning a nav mesh, be sure to do a full analyze (ie: <code>nav_analyze</code> with <code>nav_quicksave 0</code>) before publishing your nav file to others.}}
  
=Editing the Navigation Mesh=
+
= Editing the navigation mesh =
 
[[Image:nav_edit.jpg|thumb|300px|right|Enabling the Navigation Mesh editor in de_dust]]The automated Navigation Mesh generator does a reasonable job of constructing a mesh, allowing you to start using Bots and Hostages on custom maps easily.
 
[[Image:nav_edit.jpg|thumb|300px|right|Enabling the Navigation Mesh editor in de_dust]]The automated Navigation Mesh generator does a reasonable job of constructing a mesh, allowing you to start using Bots and Hostages on custom maps easily.
  
However, careful hand-tuning of the Navigation Mesh can markedly improve the performance of Bots.  In addition, manually decorating the mesh with ''Place Names'' allows the Bots to tell others where events occur, enhances the Counter-Strike radar and includes Place Names in all radio messages.
+
However, careful hand-tuning of the Navigation Mesh can noticeably improve the performance of Bots.  In addition, manually decorating the mesh with ''Place Names'' allows the Bots to tell others where events occur, enhances the Counter-Strike radar and includes Place Names in all radio messages.
 
 
==The Navigation Mesh Editor==
 
  
 +
== The navigation mesh editor ==
 
To enable the editor, type <code>nav_edit 1</code> in the console (type <code>nav_edit 0</code> to disable it).
 
To enable the editor, type <code>nav_edit 1</code> in the console (type <code>nav_edit 0</code> to disable it).
  
Line 45: Line 51:
 
* The white line in the selected area denotes where the area will be split if the <code>nav_split</code> command is executed.
 
* The white line in the selected area denotes where the area will be split if the <code>nav_split</code> command is executed.
  
===Area Types===
+
=== Area types ===
{| border="0" cellpadding="0" cellspacing="0"
+
[[Image:nav_jump.jpg|300px|thumb|left|'''Jump areas''' (marked with green X's) tell bots that they must jump to reach the higher connected area, and that this area is not usable as a hiding/sniping spot.]]
|-
+
[[Image:nav_crouch.jpg|300px|thumb|left|'''Crouch areas''' (marked with a blue diagonal slash) force bots to crouch when moving through this area.]]{{clr}}
| [[Image:nav_jump.jpg|thumb|300px|none|'''Jump areas''' (marked with green X's) tell bots that they must jump to reach the higher connected area, and that this area is not usable as a hiding/sniping spot.]]
 
| [[Image:nav_crouch.jpg|thumb|300px|none|'''Crouch areas''' (marked with a blue diagonal slash) force bots to crouch when moving through this area.]]
 
|}
 
 
 
===Connection Types===
 
{| border="0" cellpadding="0" cellspacing="0"
 
|-
 
| [[Image:nav_connections.jpg|thumb|300px|none|'''Bidirectional (two-way) connections''' (marked with light blue lines at the area edges) allow bots to freely move between the two areas.]]
 
| [[Image:nav_jump_down.jpg|thumb|300px|none|'''One-way connections''' (marked with dark blue lines) are usually used for "jump-down" links from a high ledge to the ground.  This tells the bots that they can jump down, but they can't jump back up.  One-way links can also be useful for forcing bots to travel a specific direction, perhaps to set up for a tricky jump.]]
 
|}
 
  
==Using Mesh Editing Commands==
+
== Using mesh editing commands ==
 
Although all of the mesh editing commands can be typed in the console, in practice it is far easier to ''bind'' these commands to keys.  For example, <code>bind del nav_delete</code> binds the delete key to the command nav_delete.  After this binding, pressing the delete key will delete the nav area under your cursor (if you are nav editing mode).  
 
Although all of the mesh editing commands can be typed in the console, in practice it is far easier to ''bind'' these commands to keys.  For example, <code>bind del nav_delete</code> binds the delete key to the command nav_delete.  After this binding, pressing the delete key will delete the nav area under your cursor (if you are nav editing mode).  
  
You can temporarily bind many commands at once by using a CFG file.  This is useful for bot navigation editing, because there are many commands, and you will probably not want them to be permanently attached to your keys. See [[Bot Navigation Editing CFG File]] for a pre-made file and instructions on its use.
+
You can temporarily bind many commands at once by using a CFG file.  This is useful for bot navigation editing, because there are many commands, and you will probably not want them to be permanently attached to your keys. See [[Editing Bot Navigation CFG File]] for a pre-made file and instructions on its use.
  
 
See [[Counter-Strike: Source Navigation Mesh Console Command Reference|Navigation Mesh Console Command Reference]] for a list of all commands related to bot navigation.
 
See [[Counter-Strike: Source Navigation Mesh Console Command Reference|Navigation Mesh Console Command Reference]] for a list of all commands related to bot navigation.
  
==Basic Mesh Editing Commands==
+
== Basic mesh editing commands ==
===Save===
+
=== Save ===
 
Currently, there is no "undo" command in the Navigation Mesh editing system.  Therefore, it is very important to '''save your work often''' via the <code>nav_save</code> command.
 
Currently, there is no "undo" command in the Navigation Mesh editing system.  Therefore, it is very important to '''save your work often''' via the <code>nav_save</code> command.
  
===Split===
+
=== Split ===
 
To split an area into two adjacent, inter-connected areas, aim your cursor at an area and execute the <code>nav_split</code> command.
 
To split an area into two adjacent, inter-connected areas, aim your cursor at an area and execute the <code>nav_split</code> command.
[[Image:nav_edit.jpg|400px|Before split]]
 
[[Image:nav_split.jpg|400px|After split]]
 
  
===Merge===
+
[[Image:nav_edit.jpg|300px|thumb|left|Before split]]
 +
[[Image:nav_split.jpg|300px|thumb|left|After split]]{{clr}}
 +
 
 +
=== Merge ===
 
To merge two adjacent areas:
 
To merge two adjacent areas:
 
# Aim your cursor at the first area and execute <code>nav_mark</code>
 
# Aim your cursor at the first area and execute <code>nav_mark</code>
Line 82: Line 79:
 
Note that both areas must be the same size along the edge to be merged.
 
Note that both areas must be the same size along the edge to be merged.
  
[[Image:nav_mark.jpg|300px|Marked first area]]
+
[[Image:nav_mark.jpg|300px|thumb|left|Marked first area]]
[[Image:nav_pre_merge.jpg|300px|Aim at second area]]
+
[[Image:nav_pre_merge.jpg|300px|thumb|left|Aim at second area]]
[[Image:nav_post_merge.jpg|300px|Merged]]
+
[[Image:nav_post_merge.jpg|300px|thumb|left|Merged]]{{clr}}
  
The resulting area will retain all of the connections of the original two areas, and inherit properties (ie: Place Names, etc) from the marked area.
+
The resulting area will retain all of the connections of the original two areas, and inherit properties (i.e: Place Names, etc) from the marked area.
  
===Splice===
+
=== Splice ===
 
Splicing creates a new area between two existing areas.  Splicing is a powerful tool, and can be used to easily create sloped areas, as shown in the example below.
 
Splicing creates a new area between two existing areas.  Splicing is a powerful tool, and can be used to easily create sloped areas, as shown in the example below.
  
Line 95: Line 92:
 
# Aim your cursor at the second area and execute <code>nav_splice</code>
 
# Aim your cursor at the second area and execute <code>nav_splice</code>
  
[[Image:nav_prep_splice.jpg|300px|Marked first area]]
+
[[Image:nav_prep_splice.jpg|300px|thumb|left|Marked first area]]
[[Image:nav_pre_splice.jpg|300px|Aim at second area]]
+
[[Image:nav_pre_splice.jpg|300px|thumb|left|Aim at second area]]
[[Image:nav_post_splice.jpg|300px|New area spliced between]]
+
[[Image:nav_post_splice.jpg|300px|thumb|left|New area spliced between]]{{clr}}
  
===Delete===
+
=== Delete ===
 
To delete an area, aim your cursor at it and execute <code>nav_delete</code>
 
To delete an area, aim your cursor at it and execute <code>nav_delete</code>
  
===Creating a New Area===
+
=== Creating a new area ===
 
To manually create a new area:
 
To manually create a new area:
 
# Place your cursor at where a corner of the new area should be
 
# Place your cursor at where a corner of the new area should be
Line 109: Line 106:
 
# Execute <code>nav_end_area</code>
 
# Execute <code>nav_end_area</code>
  
[[Image:nav_begin_area.jpg|300px|Start dragging area at first corner]]
+
[[Image:nav_begin_area.jpg|300px|thumb|left|Start dragging area at first corner]]
[[Image:nav_drag_area.jpg|300px|Drag area extent]]
+
[[Image:nav_drag_area.jpg|300px|thumb|left|Drag area extent]]
[[Image:nav_end_area.jpg|300px|Area created]]
+
[[Image:nav_end_area.jpg|300px|thumb|left|Area created]]{{clr}}
  
===Adding and Removing Connections Between Areas===
+
=== Adding and removing connections between areas ===
 
The connections between areas define whether an agent can move from one area to another. Usually these connections are ''bidirectional'', meaning agents can move back and forth between two areas at will.  However, sometimes the connection is ''one way'', as in the case of high ledges that can be jumped down, but not back up.
 
The connections between areas define whether an agent can move from one area to another. Usually these connections are ''bidirectional'', meaning agents can move back and forth between two areas at will.  However, sometimes the connection is ''one way'', as in the case of high ledges that can be jumped down, but not back up.
  
To make a one-way connection from area A to area B (meaning you can move from A to B):
+
To make a '''<span style="color: rgb(0, 51, 153);">one-way connection</span>''' from area A to area B (meaning you can move from A to B):
 
# Place your cursor on area A
 
# Place your cursor on area A
 
# Mark area A with <code>nav_mark</code>
 
# Mark area A with <code>nav_mark</code>
Line 122: Line 119:
 
# Execute <code>nav_connect</code>
 
# Execute <code>nav_connect</code>
  
To make a bidirectional connection, repeat the above steps reversing the roles of A and B.
+
To make a '''<span style="color: rgb(51, 204, 204);">bidirectional connection</span>''', repeat the above steps reversing the roles of A and B.
  
 
To remove all connections from areas A and B:
 
To remove all connections from areas A and B:
Line 130: Line 127:
 
# Execute <code>nav_disconnect</code>
 
# Execute <code>nav_disconnect</code>
  
==Adding Place Names==
+
[[Image:nav_jump_down.jpg|300px|thumb|left|'''One-way connections''' (marked with dark blue lines) are usually used for "jump-down" links from a high ledge to the groundThis tells the bots that they can jump down, but they can't jump back up.  One-way links can also be useful for forcing bots to travel a specific direction, perhaps to set up for a tricky jump.]]
''Place Names'' can be assigned to areas to label that region of the mapFor instance, if there is a prominent house in the map, all of the nav areas in the house can be tagged with the "House" Place Name.
+
[[Image:nav_connections.jpg|300px|thumb|left|'''Bidirectional (two-way) connections''' (marked with light blue lines at the area edges) allow bots to freely move between the two areas.]]{{clr}}
  
Place Names are used by the CS Bot chatter system to announce where they are, as well as by the radar to show the current location of the player, and is appended to the player's name when they use text chat or radio commands.
+
== Adding place names ==
 +
Once you've generated a nav mesh, ''Place Names'' can be assigned to nav areas to label that region of the map.  For instance, if there is a prominent house in the map, all of the nav areas in the house can be tagged with the "House" Place Name.
  
To enter and leave "Place Painting Mode", execute <code>nav_toggle_place_mode</code> (assuming <code>nav_edit</code> is set to "1").
+
Place Names are used by the CS Bot chatter system to announce where they are, by the radar to show the current location of the player, and they are appended to the player's name when that player uses text chat or radio commands. For example:
 +
:<code>ChicagoTed @ '''Apartment''' (RADIO): Fire in the hole!</code>
  
For a list of all available Place Names, execute <code>nav_place_list</code>.
+
To add or change the name of a location, you need to turn on the place name editor.  If you haven't already done so, you'll want to first make sure <code>nav_edit</code> is set to "1", then type <code>nav_toggle_place_mode</code>.  When the place name editor is enabled (assuming no areas have been named) all the nav squares should turn red.
  
Select a Place by typing <code>nav_use_place (name)</code>.  Then aim your cursor at an area you want to label with that Place Name and execute <code>nav_toggle_place_painting</code>.  While "place painting" is active, each area you point at will be tagged with the current Place Name.  To stop place painting, execute <code>nav_toggle_place_painting</code> again.
+
To select which ''Place Name'' you want to assign to an area, type <code>nav_use_place (name)</code>, for example <code>nav_use_place Bedroom</code>.  Next, aim your cursor at an area you want to label with that ''Place Name'' and turn on "Place Painting Mode"  by executing <code>nav_toggle_place_painting</code>.  While "place painting" is active, each area you point at will be tagged with the current ''Place Name'' you selected and will turn green in colorYou can change the place name you are painting with by typing <code>nav_use_place (newname)</code>, notice that after changing the place name, all areas already painted with a different name will turn blue and areas painted with the name you just changed to will turn green.  When you are finished using "Place Painting Mode", you can exit by executing <code>nav_toggle_place_painting</code> again.
  
There are several additional commands that provide tools for picking, flood-filling, replacing, and so on.  For a complete reference, see [[#Place Name Commands|Place Name Commands]].
+
For a list of all available Place Names, execute <code>nav_place_list</code>.  Or, if you are working on a CSS, or CS:GO map, you can find a list of available names in the following articles: [[Standard Place Names for CSS]], [[Standard Place Names for CS:GO]] .
  
==Common Mesh Problems and Solutions==
+
There are several additional commands that provide tools for picking, flood-filling, replacing, and so on.  For a complete reference, see [[Navigation_Mesh_Commands#Place_name_commands|Place Name Commands]].
===Extraneous Areas on Stairs and Ramps===
+
 
 +
== Common mesh problems and solutions ==
 +
=== Extraneous areas on stairs and ramps ===
 
The automatic generation system tends to build areas that hang off the side of stairs and ramps.  These should be removed to force the bots to take the stairs or ramp straight-on.
 
The automatic generation system tends to build areas that hang off the side of stairs and ramps.  These should be removed to force the bots to take the stairs or ramp straight-on.
  
===Railings===
+
=== Railings ===
Railings can be a problem for the current bot navigation system.  Including jump-down links that must pass over railings should be avoided unless necessary.  The bots will eventually make these jumps, but they are not terribly elegant while doing so.
+
Railings can be a problem for the current bot navigation system, this includes jump-down links that must pass over railings, they should be avoided unless necessary.  The bots will eventually make these jumps, but they are not terribly elegant while doing so.
 +
 
 +
=== Preventing excessive jumping ===
 +
Mark an area with <code>nav_mark</code> and use the <code>nav_no_jump</code> command to flag the area to discourage jumping.
  
===Preventing Excessive Jumping===
+
=== Dealing with rotating doors ===
When to use the <code>nav_no_jump</code> flag.
+
Clip off the nav area to leave an empty space in the nav mesh to allow for the rotating door. You may have to remake the nav square if deleting part of an existing one doesn't work.
  
===Dealing with Rotating Doors===
+
Bots will sometimes try to walk through the opened door brush from one nav area to another and get stuck. Either removing the adjacent nav area or configuring the areas and connections so the bots have to walk around the opened door should prevent this.
Carving out empty space in the nav mesh to allow for the rotating door.
 
  
==Advanced Editing Techniques==
+
== Advanced editing techniques ==
 +
=== Adding additional meshes ===
 +
Create a point of generation using nav_mark_walkable in an area without meshes and use the command nav_generate_incremental to generate a new area from that point. Use nav_generate_incremental_range to specify the range of the point generation.
  
===Ladders===
+
=== Ladders ===
 
Ladders can be manually built against climbable surfaces.  Your editing cursor will turn green when pointing at a climbable surface.
 
Ladders can be manually built against climbable surfaces.  Your editing cursor will turn green when pointing at a climbable surface.
  
Line 165: Line 170:
 
The easy way to build a ladder is to simply point at a climbable surface, and execute <code>nav_build_ladder</code>.
 
The easy way to build a ladder is to simply point at a climbable surface, and execute <code>nav_build_ladder</code>.
  
[[Image:nav_build_ladder_before.jpg|300px|Point at a climbable surface]]
+
[[Image:nav_build_ladder_before.jpg|300px|thumb|left|Point at a climbable surface]]
[[Image:nav_build_ladder_after.jpg|300px|Ladder created]]
+
[[Image:nav_build_ladder_after.jpg|300px|thumb|left|Ladder created]]{{clr}}
  
 
'''Using <code>nav_begin_area</code> and <code>nav_end_area</code>'''
 
'''Using <code>nav_begin_area</code> and <code>nav_end_area</code>'''
Line 178: Line 183:
 
This can be useful to get bots to start going up the ladder, and jump off halfway up, onto the crate:
 
This can be useful to get bots to start going up the ladder, and jump off halfway up, onto the crate:
  
[[Image:nav_begin_ladder.jpg|300px|Start dragging ladder at first corner]]
+
[[Image:nav_begin_ladder.jpg|300px|thumb|left|Start dragging ladder at first corner]]
[[Image:nav_drag_ladder.jpg|300px|Drag ladder extent]]
+
[[Image:nav_drag_ladder.jpg|300px|thumb|left|Drag ladder extent]]
[[Image:nav_end_ladder.jpg|300px|Ladder created]]
+
[[Image:nav_end_ladder.jpg|300px|thumb|left|Ladder created]]{{clr}}
 
 
'''Reversing ladders'''
 
  
 +
=== Reversing ladders ===
 
Sometimes a ladder will be created facing the wrong way.  If a ladder is drawn in red, you are looking at it from the back.  The ladder is drawn in green if it is facing you.  To change the orientation of a ladder, simply point at the ladder and use <code>nav_ladder_flip</code>.
 
Sometimes a ladder will be created facing the wrong way.  If a ladder is drawn in red, you are looking at it from the back.  The ladder is drawn in green if it is facing you.  To change the orientation of a ladder, simply point at the ladder and use <code>nav_ladder_flip</code>.
  
[[Image:nav_ladder_backward.jpg|300px|Ladder facing into the wall (incorrect)]]
+
[[Image:nav_ladder_backward.jpg|300px|thumb|left|Ladder facing into the wall (incorrect)]]
[[Image:nav_ladder_forward.jpg|300px|Ladder facing away from the wall (correct)]]
+
[[Image:nav_ladder_forward.jpg|300px|thumb|left|Ladder facing away from the wall (correct)]]{{clr}}
  
===Obstacle Avoidance and Precision Movement===
+
=== Obstacle avoidance and precision movement ===
 
Using <code>nav_precise</code>, <code>nav_walk</code>, and <code>nav_stop</code> to disable local obstacle avoidance behaviors and control bot movement.
 
Using <code>nav_precise</code>, <code>nav_walk</code>, and <code>nav_stop</code> to disable local obstacle avoidance behaviors and control bot movement.
  
===Marking Areas to Avoid===
+
=== Marking areas to avoid ===
 
Using <code>nav_avoid</code> to tell bots to avoid the area unless the normal route has become too dangerous.
 
Using <code>nav_avoid</code> to tell bots to avoid the area unless the normal route has become too dangerous.
  
===Controlling Where Bots Can Hide===
+
=== Controlling where bots Can hide ===
Using <code>nav_no_hide</code> to prevent bots from hiding in that area.
+
Using <code>nav_dont_hide</code> to prevent bots from hiding in that area.
How to force the creation of hiding spots during the analysis phase.
+
This can be used to force the creation of hiding spots during the analysis phase.
 +
 
 +
=== Setting up sniper spots ===
 +
Mark an area using <code>nav_walk</code> and execute <code>nav_make_sniper_spots</code>. This will break the area into small sub-areas which are used internally by the navigation mesh to encourage sniping.
  
===Lining up Tricky Jumps and Narrow Doorways===
+
=== Lining up tricky jumps and narrow doorways ===
 
Arranging nav areas to force specific paths.
 
Arranging nav areas to force specific paths.
  
Line 205: Line 212:
 
* The highest a bot will try to jump is 58 units.  If the top of a jump is 59 or more units above the bottom, bots will give up as soon as they jump.  If this happens in a spot that the bots can actually jump up to, use <code>nav_corner_lower</code> to lower the upper nav area slightly.
 
* The highest a bot will try to jump is 58 units.  If the top of a jump is 59 or more units above the bottom, bots will give up as soon as they jump.  If this happens in a spot that the bots can actually jump up to, use <code>nav_corner_lower</code> to lower the upper nav area slightly.
  
[[Image:MaximumJumpCrouch.jpg|300px|Highest possible crouchjump]]
+
[[Image:MaximumJumpCrouch.jpg|300px|thumb|left|Highest possible crouchjump]]{{clr}}
 +
 
 +
= Game Specific SubVersions =
 +
{| class="standard-table"
 +
! Game !! Known as !! Subversion !! Notes
 +
|-
 +
| {{game link|Garry's Mod}}
 +
| TheNavMesh
 +
| 0
 +
| Garry's Mod is using the base navigation mesh(It doesn't use it's own implementation unlike Valve games)
 +
|-
 +
| {{game link|Counter-Strike: Source}}
 +
| CSNavMesh
 +
| 1
 +
|
 +
|-
 +
| {{game link|Team Fortress 2}}
 +
| CTFNavMesh
 +
| 2
 +
|
 +
|-
 +
| {{game link|Left 4 Dead}}
 +
| TerrorNavMesh
 +
| 13
 +
|
 +
|-
 +
| {{game link|Left 4 Dead 2}}
 +
| TerrorNavMesh
 +
| 14
 +
|
 +
|-
 +
| {{game link|Counter-Strike: Global Offensive}}
 +
| CSNavMesh
 +
| 1
 +
| (Ported from Counter Strike: Source?)
 +
|}
 +
 
 +
= See also =
 +
* [[Navigation Mesh Commands|Navigation Mesh Console Command Reference]]
 +
* [[Left 4 Dead Navigation Meshes]]
 +
* [[L4D Level Design/Nav Meshes]]
 +
* [[L4D Level Design/Nav Flow]]
 +
* [[L4D Level Design/Advanced Nav Editing]]
  
=See also=
+
= External Links =
 +
* Official forums for the bot system (down) - [http://web.archive.org/web/*/http://www.turtlerockstudios.com/forums/csbot/ Archived version].
 +
* [http://www.editlife.net/tutorial.php?tutid=60 Waypointing for CS:S Bots/Hostages (Edit Life)]
  
[[Counter-Strike: Source Navigation Mesh Console Command Reference|Navigation Mesh Console Command Reference]]
 
  
[http://www.turtlerockstudios.com/forums/csbot/viewtopic.php?t=725 Official forums for the bot system].
+
[[Category:Level Design]]

Latest revision as of 17:23, 2 November 2019

日本語

A Navigation Mesh represents the "walkable areas" of a map. This data is required by Bots and Hostages in Counter-Strike: Source and Counter-Strike: Global Offensive, and all NextBot entities in Left 4 Dead, Left 4 Dead 2 and Team Fortress 2, allowing them to "know" how to move around in the environment.

Navigation Mesh data is stored in a NAV file corresponding to the map file (.bsp) for which it is used. For example, the nav mesh for cstrike\maps\de_dust.bsp is stored in cstrike\maps\de_dust.nav.

Automatic navigation mesh generation

To support the many community-created maps, CS:S and CS:GO include an automatic mesh generation system. The first time you attempt to play a custom map with bots, the generation system will build a .nav file for that map. Depending on the size and complexity of the map, this may take a few minutes to a few hours. Most maps take about 5 minutes to auto-generate a .nav file. Once the generation is complete, a .nav file is saved to your hard drive for future use.

For games that don't support automatic mesh generation, a navigation mesh can still be generated by a game client using the console's map command to load a map, then using sv_cheats 1, followed by nav_generate. You can then upload the created .nav file to your server.

It is recommended that map creators create navigation meshes before releasing their map to the public.

What is computed during generation

The following steps occur during Navigation Mesh generation:

  • Starting at a player spawn point, walkable space is sampled by "flood-filling" outwards from that spot, searching for adjacent walkable points
  • Rectangular Navigation Areas are constructed from the sampled data
  • Hiding and Sniper spots are computed
  • Encounter Spots and Approach Points are computed (this can take awhile)
  • Initial Encounter areas are computed

Manually starting the generation process

To start the generation process manually, type nav_generate from the console.

Viewing the navigation mesh

To see the resulting Navigation Mesh, type nav_edit 1. To turn the mesh editor off, type nav_edit 0. You will need to have sv_cheats 1 to be able to view the navigation mesh.

Explicitly marking walkable areas (i.e: "There's no mesh upstairs")

Some maps that have very steep stairs, ramps, or hills may confuse the generation system, resulting in the Navigation Mesh not covering the entire map. To solve this, you can manually place additional walkable markers that tell the generator to search outwards from that point during its sampling phase.

To add one or more walkable markers, first aim your view towards a known walkable spot in your map, then type nav_mark_walkable in the console. When you are finished placing markers, type nav_generate to re-generate the mesh.

You can remove all previously placed walkable markers using the nav_clear_walkable_marks command.

Quickly generating meshes for testing

The analysis phase of the generator can be quite time consuming. To skip it, type nav_quicksave 1 in the console.

Note:"Quicksaving" skips the analysis phase, and the resultant nav mesh will be missing important data required by the CS Bots and Hostages higher-level planning and attention systems. While useful for testing, editing, and tuning a nav mesh, be sure to do a full analyze (ie: nav_analyze with nav_quicksave 0) before publishing your nav file to others.

Editing the navigation mesh

Enabling the Navigation Mesh editor in de_dust
The automated Navigation Mesh generator does a reasonable job of constructing a mesh, allowing you to start using Bots and Hostages on custom maps easily.

However, careful hand-tuning of the Navigation Mesh can noticeably improve the performance of Bots. In addition, manually decorating the mesh with Place Names allows the Bots to tell others where events occur, enhances the Counter-Strike radar and includes Place Names in all radio messages.

The navigation mesh editor

To enable the editor, type nav_edit 1 in the console (type nav_edit 0 to disable it).

  • The white cross in the center of your view is the cursor.
  • The Navigation Area you are pointing at is the selected area and is shown with a yellow outline.
  • Navigation Areas that can be reached from the selected area are shown in red.
  • The white line in the selected area denotes where the area will be split if the nav_split command is executed.

Area types

Jump areas (marked with green X's) tell bots that they must jump to reach the higher connected area, and that this area is not usable as a hiding/sniping spot.
Crouch areas (marked with a blue diagonal slash) force bots to crouch when moving through this area.

Using mesh editing commands

Although all of the mesh editing commands can be typed in the console, in practice it is far easier to bind these commands to keys. For example, bind del nav_delete binds the delete key to the command nav_delete. After this binding, pressing the delete key will delete the nav area under your cursor (if you are nav editing mode).

You can temporarily bind many commands at once by using a CFG file. This is useful for bot navigation editing, because there are many commands, and you will probably not want them to be permanently attached to your keys. See Editing Bot Navigation CFG File for a pre-made file and instructions on its use.

See Navigation Mesh Console Command Reference for a list of all commands related to bot navigation.

Basic mesh editing commands

Save

Currently, there is no "undo" command in the Navigation Mesh editing system. Therefore, it is very important to save your work often via the nav_save command.

Split

To split an area into two adjacent, inter-connected areas, aim your cursor at an area and execute the nav_split command.

Before split
After split

Merge

To merge two adjacent areas:

  1. Aim your cursor at the first area and execute nav_mark
  2. Aim your cursor at the second area and execute nav_merge

Note that both areas must be the same size along the edge to be merged.

Marked first area
Aim at second area
Merged

The resulting area will retain all of the connections of the original two areas, and inherit properties (i.e: Place Names, etc) from the marked area.

Splice

Splicing creates a new area between two existing areas. Splicing is a powerful tool, and can be used to easily create sloped areas, as shown in the example below.

To splice a new area in between two existing areas:

  1. Aim your cursor at the first area and execute nav_mark
  2. Aim your cursor at the second area and execute nav_splice
Marked first area
Aim at second area
New area spliced between

Delete

To delete an area, aim your cursor at it and execute nav_delete

Creating a new area

To manually create a new area:

  1. Place your cursor at where a corner of the new area should be
  2. Execute nav_begin_area
  3. Move your cursor to drag out the area's extent
  4. Execute nav_end_area
Start dragging area at first corner
Drag area extent
Area created

Adding and removing connections between areas

The connections between areas define whether an agent can move from one area to another. Usually these connections are bidirectional, meaning agents can move back and forth between two areas at will. However, sometimes the connection is one way, as in the case of high ledges that can be jumped down, but not back up.

To make a one-way connection from area A to area B (meaning you can move from A to B):

  1. Place your cursor on area A
  2. Mark area A with nav_mark
  3. Aim your cursor at area B
  4. Execute nav_connect

To make a bidirectional connection, repeat the above steps reversing the roles of A and B.

To remove all connections from areas A and B:

  1. Aim at area A
  2. Mark area A with nav_mark
  3. Aim at area B
  4. Execute nav_disconnect
One-way connections (marked with dark blue lines) are usually used for "jump-down" links from a high ledge to the ground. This tells the bots that they can jump down, but they can't jump back up. One-way links can also be useful for forcing bots to travel a specific direction, perhaps to set up for a tricky jump.
Bidirectional (two-way) connections (marked with light blue lines at the area edges) allow bots to freely move between the two areas.

Adding place names

Once you've generated a nav mesh, Place Names can be assigned to nav areas to label that region of the map. For instance, if there is a prominent house in the map, all of the nav areas in the house can be tagged with the "House" Place Name.

Place Names are used by the CS Bot chatter system to announce where they are, by the radar to show the current location of the player, and they are appended to the player's name when that player uses text chat or radio commands. For example:

ChicagoTed @ Apartment (RADIO): Fire in the hole!

To add or change the name of a location, you need to turn on the place name editor. If you haven't already done so, you'll want to first make sure nav_edit is set to "1", then type nav_toggle_place_mode. When the place name editor is enabled (assuming no areas have been named) all the nav squares should turn red.

To select which Place Name you want to assign to an area, type nav_use_place (name), for example nav_use_place Bedroom. Next, aim your cursor at an area you want to label with that Place Name and turn on "Place Painting Mode" by executing nav_toggle_place_painting. While "place painting" is active, each area you point at will be tagged with the current Place Name you selected and will turn green in color. You can change the place name you are painting with by typing nav_use_place (newname), notice that after changing the place name, all areas already painted with a different name will turn blue and areas painted with the name you just changed to will turn green. When you are finished using "Place Painting Mode", you can exit by executing nav_toggle_place_painting again.

For a list of all available Place Names, execute nav_place_list. Or, if you are working on a CSS, or CS:GO map, you can find a list of available names in the following articles: Standard Place Names for CSS, Standard Place Names for CS:GO .

There are several additional commands that provide tools for picking, flood-filling, replacing, and so on. For a complete reference, see Place Name Commands.

Common mesh problems and solutions

Extraneous areas on stairs and ramps

The automatic generation system tends to build areas that hang off the side of stairs and ramps. These should be removed to force the bots to take the stairs or ramp straight-on.

Railings

Railings can be a problem for the current bot navigation system, this includes jump-down links that must pass over railings, they should be avoided unless necessary. The bots will eventually make these jumps, but they are not terribly elegant while doing so.

Preventing excessive jumping

Mark an area with nav_mark and use the nav_no_jump command to flag the area to discourage jumping.

Dealing with rotating doors

Clip off the nav area to leave an empty space in the nav mesh to allow for the rotating door. You may have to remake the nav square if deleting part of an existing one doesn't work.

Bots will sometimes try to walk through the opened door brush from one nav area to another and get stuck. Either removing the adjacent nav area or configuring the areas and connections so the bots have to walk around the opened door should prevent this.

Advanced editing techniques

Adding additional meshes

Create a point of generation using nav_mark_walkable in an area without meshes and use the command nav_generate_incremental to generate a new area from that point. Use nav_generate_incremental_range to specify the range of the point generation.

Ladders

Ladders can be manually built against climbable surfaces. Your editing cursor will turn green when pointing at a climbable surface.

Using nav_build_ladder

The easy way to build a ladder is to simply point at a climbable surface, and execute nav_build_ladder.

Point at a climbable surface
Ladder created

Using nav_begin_area and nav_end_area

If nav_build_ladder isn't what you need, you can manually create a ladder:

  1. Place your cursor at where a corner of the new ladder should be
  2. Execute nav_begin_area
  3. Move your cursor to drag out the ladder's extent
  4. Execute nav_end_area

This can be useful to get bots to start going up the ladder, and jump off halfway up, onto the crate:

Start dragging ladder at first corner
Drag ladder extent
Ladder created

Reversing ladders

Sometimes a ladder will be created facing the wrong way. If a ladder is drawn in red, you are looking at it from the back. The ladder is drawn in green if it is facing you. To change the orientation of a ladder, simply point at the ladder and use nav_ladder_flip.

Ladder facing into the wall (incorrect)
Ladder facing away from the wall (correct)

Obstacle avoidance and precision movement

Using nav_precise, nav_walk, and nav_stop to disable local obstacle avoidance behaviors and control bot movement.

Marking areas to avoid

Using nav_avoid to tell bots to avoid the area unless the normal route has become too dangerous.

Controlling where bots Can hide

Using nav_dont_hide to prevent bots from hiding in that area. This can be used to force the creation of hiding spots during the analysis phase.

Setting up sniper spots

Mark an area using nav_walk and execute nav_make_sniper_spots. This will break the area into small sub-areas which are used internally by the navigation mesh to encourage sniping.

Lining up tricky jumps and narrow doorways

Arranging nav areas to force specific paths.

  • If the bots are getting hung up on the sides of a door or window, you can carve out a narrow path through the middle of the opening.
  • The highest a bot will try to jump is 58 units. If the top of a jump is 59 or more units above the bottom, bots will give up as soon as they jump. If this happens in a spot that the bots can actually jump up to, use nav_corner_lower to lower the upper nav area slightly.
Highest possible crouchjump

Game Specific SubVersions

Game Known as Subversion Notes
<Garry's Mod> Garry's Mod TheNavMesh 0 Garry's Mod is using the base navigation mesh(It doesn't use it's own implementation unlike Valve games)
<Counter-Strike: Source> Counter-Strike: Source CSNavMesh 1
<Team Fortress 2> Team Fortress 2 CTFNavMesh 2
<Left 4 Dead> Left 4 Dead TerrorNavMesh 13
<Left 4 Dead 2> Left 4 Dead 2 TerrorNavMesh 14
<Counter-Strike: Global Offensive> Counter-Strike: Global Offensive CSNavMesh 1 (Ported from Counter Strike: Source?)

See also

External Links