L4D Level Design/Nav Meshes

Jump to: navigation, search

Contents

[hide]

[edit] Your First Nav Mesh

In Hammer, open your first map file "tutorial01.vmf"

Go to File > Save As and rename it to "tutorial04.vmf"

Press F9 and click on the OK Button to compile it.

[edit] Getting Started

When the level loads, bring down your console (`) and use "director_stop" and press the Enter Key. Then, use "nb_delete_all" and press the Enter Key. Hide the console (`).

You will see an error message appear.

The Map is unplayable error message.
The Map is unplayable error message.

Click on CONTINUE to close the message.

You will notice that you are outside of your level – probably below the first room you created.

Bring down your console (`) and type "noclip" and press the Enter Key. Then hide the console (`).

Look up at the first room and move there with your move forward key. Once you're inside the first room, you can type "noclip" again in your console to turn off noclip. You should be standing in the first room you made.

Bring down the console and this time type "nav_edit 1" and press Enter.

[edit] Generating a New Nav Mesh

Positioning the cursor.
Positioning the cursor.

Hide the console and look at the floor in the middle of the hallway between the two rooms.


Placing a nav_mark_walkable.
Placing a nav_mark_walkable.

Bring down the console and type "nav_mark_walkable" and press Enter.

When you hide your console you should see a pyramid-like shape where you are pointing.

You have just placed a nav generation marker called a "nav_mark_walkable".


The nav areas automatically generated.
The nav areas automatically generated.

Bring down your console again and type "nav_generate_incremental" and press Enter.

This will generate a nav areas around the nav_mark_walkable and it should generate throughout your level.


Image:note.png Note: If you have a bigger level, you will need to place more of the nav_mark_walkable markers throughout your level. Each nav_mark_walkable has a radius that it creates areas around. In general, build nav areas for one section at a time to keep the nav mesh clean.

Nav_generate_incremental automatically saves the nav mesh when it is run. If you want to save manually, use "nav_save" from the console.

[edit] Nav Area Selection

First of all, when nav_generate_incremental is run, all of the new nav areas it creates stay selected. This comes in handy if you make a mistake and want to run the generation again. You can just type "nav_delete" in the console to delete all nav areas that are selected. To deselect them, type "nav_clear_selected_set".

To select a nav area, point at the area with your cursor and type "nav_toggle_in_selected_set"

This will select the nav area you are pointing at.

[edit] The Nav Config File

As you can tell, editing the nav uses all console commands. The most effective way to edit, instead of typing a console command each time, is to bind hot keys to these commands.

A cfg file has been enclosed that might make it easier to start with. Place "nav.cfg" in your left4dead\cfg directory.

Bring down your console and type "exec nav" and press Enter.

To bind your own keys, bring down your console and type:

bind [key] "[console command]"

For example, if you want to bind the z key to "nav_toggle_in_selected_set", type this in your console:

bind z "nav_toggle_in_selected_set"

To save your config, bring down your console and type:

host_writeconfig [name of config]

[edit] Splitting Nav Areas

You will also notice that the nav in your level currently has large areas that cover the entire room. Sometimes, it's necessary to split those large areas into smaller ones. For example, if you want to add an attribute like where the survivors start and you want the area to be right in front of the weapons table.

You can split up nav areas by using "nav_split".

The white line previews the split that you can make.
The white line previews the split that you can make.

First, bind a key to "nav_split". In the included nav.cfg file, nav_split is bound to the "v" key.

As you point at the nav areas, you will see a white line that moves either North/South or East/West with your cursor. Position the cursor so that a line draws to the right of the weapon table in the first room you created.

This line shows where the split will happen if you use nav_split.


Performing a nav_split.
Performing a nav_split.

Press your bound key to see the result.


Splitting the nav area in the other direction.
Splitting the nav area in the other direction.

Now, position the cursor so that the new area you just split in front of the weapon table is split in half in the other direction.

Press your nav_split bound key to see the result.


[edit] Adding Attributes

Nav areas may contain attributes that designate specific purposes. For example, a nav area marked with the attribute "EMPTY" means that a common infected cannot spawn on it. Let's say that you have a kitchen with a counter in it, and you don't want infected to be standing on the counter top when the player gets there because it looks weird. You can mark this area as "EMPTY".

First, type "z_debug 1" to allow the attributes to be viewed.

In our first nav mesh that we're creating, we need to designate where the Survivors are going to start when they appear in the map. Let's mark the area in front of the weapon table that we just split as "PLAYER_START"

Point your cursor at the area in front of the weapon table and use "nav_toggle_in_selected_set" or your bound key to this command (default z).

Selecting a nav area with nav_toggle_in_selected_set.
Selecting a nav area with nav_toggle_in_selected_set.

Now bring down your console and type "mark PLAYER_START" and press Enter.

Marking a nav area with the PLAYER_START attribute.
Marking a nav area with the PLAYER_START attribute.

This will turn the selected area into a Player Start position for the survivors. It should turn a purple color.

Image:note.png Note: if you mark an area with an attribute and you want to remove it later, select the area and use "clear_attribute [attribute name]" in the console to remove it.

Left 4 Dead requires certain nav areas in its levels for the director to work properly. For this simple test level, we will use another attribute called "FINALE".

Walk down to the 2nd room in this level and select the area that occupies it.

Selecting the nav area in the second room.
Selecting the nav area in the second room.

Bring down the console and type "mark FINALE" and press Enter.

Marking the nav area with the FINALE attribute.
Marking the nav area with the FINALE attribute.

This will turn this room into a finale area and it will turn blue.

Now, the level has all it needs for the director to work properly. The director can create a "flow" from the starting point to the destination point.

To make the level a little more playable, let's mark the areas around the Player Start area as "EMPTY" so that the player won't get mobbed right after jumping into the map.

Select all the areas around the Player Start.

Selecting the nav areas in the first room except the PLAYER_START area.
Selecting the nav areas in the first room except the PLAYER_START area.

Bring down the console and type "mark EMPTY" and press Enter.

Marking the selected areas with the EMPTY attribute.
Marking the selected areas with the EMPTY attribute.

This will prevent "wandering" common infected from appearing in these areas when the map starts.

Image:note.png Note: It will not prevent mobs from spawning in these areas later. You will need to add the attribute "NO_MOBS" for that.

Save the nav mesh by using "nav_save".

Image:note.png Note: If you make a mistake or if you find that the auto generation of the nav mesh has mistakes, you can delete nav areas by binding a key to "nav_delete". In the config file provided, this key is the Delete Key. For example, the weapons table doesn't actually need a nav area on top of it. It may cause survivors to stand on which might not be desirable.

[edit] Analyzing the Nav

Now that we have a basic nav mesh, we need the game to analyze it so that the director knows where it can spawn infected.

Bring down the console and type "nav_analyze" and press Enter.

This might take a few seconds and then the level will reload.

To test spawning infected, use "director_start" in the console and reload the level with "map tutorial04".

Your first nav mesh in the game.
Your first nav mesh in the game.

Your scene should look something like this now.

[edit] Adding Nav to a Ladder

If you open up tutorial03 in the game, and switch to nav_edit 1, you'll see how a ladder looks with nav placed on it.

Creating nav on a ladder.
Creating nav on a ladder.

Do create nav on a func_ladder, position your cursor over it in nav_edit mode and use "nav_build_ladder".

Image:note.png Note: The cursor will turn a green color if it is positioned over a func_ladder.

[edit] Connecting Nav Areas

While a lot of the nav areas will be connected properly when you use nav_generate_incremental, there are some that you might want to tweak or change. For example, the catwalk we created in tutorial03 might not have connected properly to the areas below it.

Connecting nav areas.
Connecting nav areas.

To connect 2 nav areas, select them and use "nav_connect" in the console. The X key is currently bound to this in the nav.cfg file.

This will connect the areas in both directions and form a light blue line as seen in this image. Infected can climb up (they can climb to any area 180 units or lower) and they can drop down. Survivor bots can also drop down.

To connect 2 areas one-way only, you will need to select the one you want to be able to connect to the other and then point to the second with the cursor but don't select it. Then, use "nav_connect".

Make sure in both cases that the 2 areas you want to connect are not layered on top of one another. This will cause infected to bump their heads when they try to climb up.

[edit] Drawing Your Own Nav Areas

Sometimes the nav_generate_incremental leaves out areas that you want to have nav on. In these cases, you will need to draw your own nav area.

First, you'll need to bind 2 keys. One key should be bound to "nav_begin_area" and the other should be bound to "nav_end_area". The nav.cfg file has nav_begin_area bound to the left mouse button and "nav_end_area" bound to the right mouse button.

Point to the area you want to create an area and click the nav_begin_area bound key. As you move the mouse around, you can see where the nav area will draw if you press the nav_end_area key.

Drawing a nav area.
Drawing a nav area.

Click the nav_end_area key to see the result.

Image:note.png Note: Creating your own nav areas will not automatically connect them to the rest of the nav mesh. Use nav_connect to connect them to adjacent areas.

If you accidentally press the nav_begin_area bound key when you don't want to draw a nav area, you can press the same key again and it will cancel the nav creation.

You might notice that the cursor doesn't snap to a grid when you're in this mode. You can set the snapping properties using "nav_snap_to_grid" in the console.

Image:tip.png Tip: It can be useful to bind a key to "incrementvar nav_snap_to_grid 0 2 1" (which is what the [ key is bound to in the nav.cfg file). This will change the grid size when you press the bound key and continue to toggle through the sizes as you continue to press the key.

It is also possible to draw a ladder using nav_begin_area and nav_end area. Simply point at a corner of the ladder and move the cursor vertically to go to the opposite corner.