Difference between revisions of "Navigation Meshes"
m ("See also" Headline code) |
MattCampbell (talk | contribs) (→Lining up Tricky Jumps and Narrow Doorways) |
||
Line 201: | Line 201: | ||
===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. | ||
+ | |||
+ | * 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 <code>nav_corner_lower</code> to lower the upper nav area slightly. | ||
+ | |||
+ | [[Image:MaximumJumpCrouch.jpg|300px|Highest possible crouchjump]] | ||
=See also= | =See also= |
Revision as of 14:18, 5 September 2005
Contents
Introduction
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.
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
.
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
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.
To see the resulting Navigation Mesh, type nav_edit 1
. To turn the mesh editor off, type nav_edit 0
.
Explicitly Marking Walkable Areas (ie: "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.
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: with
nav_quicksave 0
) before publishing your nav file to others.
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.
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
Connection Types
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 Bot Navigation Editing 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.
Merge
To merge two adjacent areas:
- Aim your cursor at the first area and execute
nav_mark
- 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.
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.
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:
- Aim your cursor at the first area and execute
nav_mark
- Aim your cursor at the second area and execute
nav_splice
Delete
To delete an area, aim your cursor at it and execute nav_delete
Creating a New Area
To manually create a new area:
- Place your cursor at where a corner of the new area should be
- Execute
nav_begin_area
- Move your cursor to drag out the area's extent
- Execute
nav_end_area
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):
- Place your cursor on area A
- Mark area A with
nav_mark
- Aim your cursor at area B
- 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:
- Aim at area A
- Mark area A with
nav_mark
- Aim at area B
- Execute
nav_disconnect
Adding Place Names
Place Names can be assigned to 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, 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.
To enter and leave "Place Painting Mode", execute nav_toggle_place_mode
(assuming nav_edit
is set to "1").
For a list of all available Place Names, execute nav_place_list
.
Select a Place by typing nav_use_place (name)
. Then aim your cursor at an area you want to label with that Place Name and execute nav_toggle_place_painting
. While "place painting" is active, each area you point at will be tagged with the current Place Name. To stop place painting, execute nav_toggle_place_painting
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.
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. 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.
Preventing Excessive Jumping
When to use the nav_no_jump
flag.
Dealing with Rotating Doors
Carving out empty space in the nav mesh to allow for the rotating door.
Advanced Editing Techniques
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
.
Using nav_begin_area
and nav_end_area
If nav_build_ladder
isn't what you need, you can manually create a ladder:
- Place your cursor at where a corner of the new ladder should be
- Execute
nav_begin_area
- Move your cursor to drag out the ladder's extent
- 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:
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
.
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_no_hide
to prevent bots from hiding in that area.
How to force the creation of hiding spots during the analysis phase.
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.