Nav Mesh: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
m (Clarify what?)
 
(161 intermediate revisions by 46 users not shown)
Line 1: Line 1:
[[Category:Level Design]]
{{LanguageBar}}


==Introduction==
A [[w:Navigation mesh|'''Navigation Mesh''']] ('''NavMesh''' or '''nav mesh''') is a data structure that stores data used for path finding, which is typically used by bots. In {{source|4}}, navigation meshes are used by the following entities:
A ''Navigation Mesh'' represents the "walkable areas" of a map. This data is '''required''' by Bots and Hostages in Counter-Strike:Source, allowing them to "know" how to move around in the environment.
# [[Bot]]s and Hostages in:
#* {{css|4}}
#* {{csgo|4}}
# [[NextBot]] entities in:
#* {{l4d|4}}
#* {{l4d2|4}}
#* {{gmod|4}}
#* {{tf2|4}}
#* {{p3|4}}
#* {{jb3|4}}
#* {{bms|4}}
…to realize what's navigable in their environment, and path to their desired destination.


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>.
==NAV file format==
{{Main|.nav}}


==Automatic Navigation Mesh Generation==
==NAV files ==
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.
Navigation Mesh data is stored in a [[NAV]] file corresponding to the map file ([[BSP|.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>.


===What is Computed During Generation===
==Navigation Mesh Editing==
The following steps occur during Navigation Mesh generation:
{{Main|Nav Mesh Editing}}
* Starting at a player spawn point, walkable space is sampled by "flood-filling" outwards from that spot, searching for adjacent walkable points
{{Main|Nav Mesh Commands}}
* Rectangular ''Navigation Areas'' are constructed from the sampled data
The Navigation Mesh Editing is done in-game. A (new) .nav file can be generated with <code>nav_generate</code> (which requires {{Command|sv_cheats|1}} and {{Command|nav_edit|1}}).
* 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===
==Game Specific SubVersions==
To start the generation process manually, type <code>nav_generate</code> from the console.
{| class="standard-table"
! Game !! Nav Mesh Class !! Subversion !! Notes
|-
| {{source|2}}
{{gmod|2}}
| TheNavMesh
| 0
| Garry's Mod uses the base navigation mesh (It doesn't use its own implementation unlike Valve games)
|-
| {{css|2}}
{{csgo|2}}
| CSNavMesh
| 1
| * Appends approach area data to each area.
|-
| {{tf2|2}}
| CTFNavMesh
| 2
| Appends TF2-specific attribute flag to area data.
|-
| {{l4d|2}}
| TerrorNavMesh
| 13
|
|-
| {{l4d2|2}}
| TerrorNavMesh
| 14
|}


===Viewing the Navigation Mesh===
==See also==
To see the resulting Navigation Mesh, type <code>nav_edit 1</code>.  To turn the mesh editor off, type <code>nav_edit 0</code>.
* [[Nav Mesh Commands|Navigation Mesh Console Command Reference]]
* [[List of L4D Series Nav Mesh Attributes]]
* [[L4D Level Design/Nav Meshes]]
* [[L4D Level Design/Nav Flow]]
* [[L4D Level Design/Advanced Nav Editing]]


===Explicity Marking Walkable Areas (ie: "There's no mesh upstairs")===
==External links==
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.
* Official forums for the bot system (down) - [http://web.archive.org/web/*/http://www.turtlerockstudios.com/forums/csbot/ Archived version].
* [https://www.editlife.net/tutorial.php?tutid=60 Waypointing for CS:S Bots/Hostages (Edit Life)]


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.
[[Category:Source]]


===Quickly Generating Meshes for Testing===
[[Category:Level Design]]<!--Why?-->
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>
 
==Editing the Navigation Mesh===
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.
 
===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).
 
 
----
 
Addition information can be found [http://www.turtlerockstudios.com/forums/csbot/viewtopic.php?t=725 here].

Latest revision as of 00:14, 8 July 2025

English (en)Deutsch (de)Esperanto (eo)Español (es)日本語 (ja)中文 (zh)Translate (Translate)

A Navigation Mesh (NavMesh or nav mesh) is a data structure that stores data used for path finding, which is typically used by bots. In Source Source, navigation meshes are used by the following entities:

  1. Bots and Hostages in:
  2. NextBot entities in:

…to realize what's navigable in their environment, and path to their desired destination.

NAV file format

Main article:  .nav

NAV files

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.

Navigation Mesh Editing

Main article:  Nav Mesh Editing
Main article:  Nav Mesh Commands

The Navigation Mesh Editing is done in-game. A (new) .nav file can be generated with nav_generate (which requires sv_cheats 1 and nav_edit 1).

Game Specific SubVersions

Game Nav Mesh Class Subversion Notes
Source Source

Garry's Mod Garry's Mod

TheNavMesh 0 Garry's Mod uses the base navigation mesh (It doesn't use its own implementation unlike Valve games)
Counter-Strike: Source Counter-Strike: Source

Counter-Strike: Global Offensive Counter-Strike: Global Offensive

CSNavMesh 1 * Appends approach area data to each area.
Team Fortress 2 Team Fortress 2 CTFNavMesh 2 Appends TF2-specific attribute flag to area data.
Left 4 Dead Left 4 Dead TerrorNavMesh 13
Left 4 Dead 2 Left 4 Dead 2 TerrorNavMesh 14

See also

External links