Sorting out navigation flow

From Valve Developer Community
Revision as of 04:34, 27 February 2010 by X6herbius (talk | contribs)
Jump to navigation Jump to search

Getting the nav flow right is one of the hardest parts in creating a good, working Left 4 Dead map. If the flow from the start to the end of the map isn't valid, survivors may not be able to reach the end safe room or finale, rescue closets might not work and the wandering infected will not spawn.

This is a checklist that I have compiled as I've overcome problems in my nav mesh generation. Please feel free to add to this if you discover any other useful methods/pieces of information.

Introduction

Firstly, the standard Left 4 Dead campaigns consist of five levels. The first level contains the original player spawn area (referred to in the navigation mesh as PLAYER START) and proceeds to a safe room (CHECKPOINT). The next three maps go from safe room to safe room and the last map ends in a finale (FINALE). Any campaign you build is not limited to five maps, but using the standard campaign basis as an example, this is the general flow:

  • PLAYER START to CHECKPOINT - eg. l4d_airport01_greenhouse.bsp - "Player Start" map.
  • CHECKPOINT to CHECKPOINT - eg. l4d_airport02_offices.bsp - "Checkpoint" map.
  • CHECKPOINT to CHECKPOINT - eg. l4d_airport03_garage.bsp - "Checkpoint" map.
  • CHECKPOINT to CHECKPOINT - eg. l4d_airport04_terminal.bsp - "Checkpoint" map.
  • CHECKPOINT to FINALE - eg. l4d_airport05_runway.bsp - "Finale" map.

Depending on how many maps your campaign has, the CHECKPOINT to CHECKPOINT does not necessarily have to exist. You could have PLAYER START to CHECKPOINT and then CHECKPOINT to FINALE, or just plain PLAYER START to FINALE.

Note that if you only have a single map (that doesn't lead onto others), the only technically correct format for this is PLAYER_START to FINALE. It is possible to create a single standalone map that does not utilise a finale, and this just involves creating an ending safe room as usual but putting a dummy value in the trigger_changelevel to tell it what map to switch to. As long as you include the next map value the navigation flow will be valid but when your players finish the level the game will not exit correctly, since there will be an error in the console saying the next map cannot be found. Ideally, the best way to play through a standalone map is with a finale at the end, as the dummy chckpoint looks fairly unprofessional.

Note.pngNote:In the player spawn area (this does not apply to safe rooms, just the first map in a campaign), there should be at least one PLAYER START navigation sector. The four info_survivor_positions and one info_player_start should be located on one or more sectors marked with the PLAYER START attribute. These sectors should also be completely surrounded by sectors marked CHECKPOINT. I don't know if all of this is strictly necessary for a valid flow but, for good practice, I'd recommend sticking to this basis.

Console Commands

To start editing the navigation mesh, type exec nav_mode into the console. This sets up Valve's configuration for nav editing and is very useful in accessing all the commands you will need to use. To quit the nav editing mode, press Page Down; note that this doesn't always seem to remove all editing functions, so you may need to type exec config_default afterwards to reset your controls to the default configuration.

The best way to get to know the commands is to open up the nav_mode.cfg file yourself and make a list of the keys. However, some very useful editing commands are below:

  • z_spawn (default 1) - This spawns a normal zombie at your crosshair. If you add a parameter after the command the relevant zombie will be spawned; for example, "z_spawn tank" will spawn a tank.
  • noclip (default n) - Allows you to fly around the map and through objects. Very useful in positioning yourself for editing high-up areas or for getting to a specific area of your map quickly.
  • nav_save (default TAB) - Saves your navigation mesh. Do this often, as there's no function for undoing changes if you mess things up!
  • director_start/stop (default F3) - Toggles the director's enabled/disabled state. If enabled (and your flow is valid), wandering zombies will spawn, tanks and witches will spawn, etc.
  • respawn_bot (default Numpad DEL) - This respawns a random bot. Note that this is a custom alias created in the nav_mode.cfg file and so will not function unless you have exec'd the file. The alias "respawn_bots" respawns all four bots but is not bound to a key by default.
  • warp_all_survivors_here (default ' [apostrophe]) - Warps all survivors (including you) to the spot under your crosshair.
  • nb_delete_all (default 2) - Deletes all NPCs (zombies, specials, survivors) from the world.
  • nb_move_to_cursor (default 3) - Tells all NPCs to move towards the point under your crosshair. The target point is marked temporarily with a small green cross.
  • nav_simplify_selected (default F7) - Attempts to merge any nav areas you have selected to simplify them. Don't try this with the whole map selected as the game will crash.
  • nav_gui (default F6) - Opens up the nav-editing GUI with some advanced options. Note that the nav_gui command will need to be typed again to close the window and re-enable movement.
  • nav_trouble_report (default PgUp) - Runs a check for the common problems present in navigation meshes. Any problem areas will be highlighted and the number of errors displayed in the console. Try typing the command in the console and add a space to see the different parameters that can be given.

There are also some other very useful commands that are not included in the config:

  • z_show_flow_delta 1/2 - This enables flow arrows on the nav sector that you're looking at (if set to 1) or all nav sectors in the area (if set to 2).
  • z_show_flow_distance 1 - This enables the flow distance to be displayed: xxxx/xxxx. These numbers relate to the units increasing towards map goal/units increasing from start. If -9999/-9999, the flow to this nav area is broken.

Recomputing The Flow

The most common error you'll encounter while nav-editing is the flow error. For a map to work properly there must be distinguishable start and end points and a completely connected route through the map. The director uses the flow to work out how far the survivors are through the map, which areas are in front of them and which are behind.

If when running a map you get a large "Map is unplayable!" error at the start, it's likely that your flow is broken. To fix this, one magic command can help tremendously in debugging: nav_recompute_flow. The command attempts to hook up your starting area (PLAYER_START or CHECKPOINT) with the ending area (CHECKPOINT or FINALE); if it can't, one of these possible errors will be displayed in the console:

  • GetGoalArea: Cannot find SPAWN_RESCUE_CLOSET area in FINALE, thus cannot guarantee reachability of goal area.

If your current map is a finale map, you will need to create at least one rescue closet available to the survivors before they reach the finale area. This ensures that there is an available place for the survivors to respawn in the map if they die, since there's no ending safe room present.

Todo: Do we always need a rescue closet? I didn't have one in my recent finale and it didn't complain.

If your map is not a finale map, this means there is a problem with your ending safe room. The game cannot find a second checkpoint area in the map and so assumes that it has a finale event. Of course, it then cannot find any nav areas marked FINALE and so reports the finale as broken. See the third item on the checklist below for a list of the entities required in an ending safe room.

  • ComputeFlowDistances: ERROR - [Error here]

Depending on what error is being reported, this may be because of a number of problems:

    • Cannot determine start/end area - This means you have not set up your beginning/ending checkpoint or finale correctly. See the checklist below for more information.
    • Cannot reach start area from end area - This is the easiest of the nav errors and simply means that you have a break in your nav connections somewhere along the line. You can use nav_trouble_report orphan to check for disconnected nav areas and z_show_flow_distance/delta to check the flow ID for each area. Look out for dark blue (one-way) connections which could be pointing backwards, ie. the survivors will be able to walk from the further area to the nearer area but not the other way around. Left 4 Dead also commonly mucks up the meshes on stairs, so these would be your first culprits to check.
Note.pngNote:I recently had trouble with navigation flow regarding this - it turned out, after a lot of investigation, that one of my nav areas was marked as a checkpoint when it shouldn't have been. If you're having the same problem where this error won't go away, an easy way to find the rogue area is to type z_show_flow_distance 1 and look for any numbers that say either xxxx/-9999 or -9999/xxxx. Follow these numbers in the direction that they decrease and you should find your unwanted checkpoint.
  • GetGoalArea: Cannot find end area - no checkpoint or finale located.

This means that none of your nav areas have been marked with either CHECKPOINT or FINALE. If you want a checkpoint, you've probably done something wrong concerning your safe rooms - see the third item on the cheklist below. If you want a finale, you need to apply the mark FINALE attribute liberally to the navigation sectors in your finale area.

Correctly Setting Up Checkpoints

For the flow to be computed correctly, it is highly recommended to follow these gidelines:

Survivor Spawn Point

This is the point at which the survivors originally spawn in the very first map of a campaign. You will need:

  • Four info_survivor_position entities, placed slightly above the ground. Each one will need to have a unique "Order" value and a unique survivor name out of Zoey, Bill, Francis and Louis.
  • A weapon_ammo_spawn. This is very important as, bizzarely, it is also used to help determine the flow through a map. If a weapon_ammo_spawn at minimum is not present in either a beginning or ending checkpoint (an area with nav squares marked as CHECKPOINT), the game may not recognise it as a valid checkpoint area. Crazy, I know.
Note.pngNote:If your ammo spawn in on a table it may be required to create a nav sector on top of the table and connect it up, just to make sure that the ammo spawn sits over CHECKPOINT nav.
  • An info_player_start, placed slightly above the ground. It is recommended to mark the nav sector directly underneath this with the PLAYER_START attribute.
  • Four weapon_first_aid_kit_spawns and low powered weapon spawns (weapon_smg_spawn, weapon_pumpshotgun_spawn) are also recommended. Note that any item spawns that are in checkpoints do not need the "Must Exist" flag ticked; they will always be forced to spawn.


The navigation mesh must be as follows:

  • One single square of nav marked as PLAYER_START.
  • A fair radius around this marked as CHECKPOINT. It doesn't really matter too much how big this area actually is, but bear in mind that zombies will not be allowed to spawn on it (same with infected players in Versus mode). Don't make this too small, either; it needs to have plenty of room to cover the survivor's spawn points and any weapon spawns.
  • It is recommended to cover a little of the surrounding non-checkpoint nav with the EMPTY attribute, as this will prevent zombies from spawning too near the survivors at the start of the game while not contributing to the checkpoint area. The EMPTY attribute is also recommended for a little way outside of beginning safe rooms.

End Safe Room

This is any safe room at the end of a map which leads onto the next map. You will need:

  • A prop_door_rotating_checkpoint. This is essential to the mechanics of a safe room and must not be a plain prop_door_rotating. It is also highly recommended to name this door "checkpoint_entrance" (to "enter" the safe room) and to set the keyvalue to start open (in whichever direction is most convenient).
Note.pngNote:The checkpoint door names are the opposite way around to they way you'd expect: the starting door exits the previous safe room, the ending door enters the next one.
  • A trigger_changelevel. The trigger volume should be at least flush with the floor of your safe room and should touch the majority of it (the game works out which nav sectors should be marked as CHECKPOINTby the presence of this volume). The "New Map Name" value absolutely must have something in it, although it does not specifically matter whether the specified map exists or not (if it does not, the safe room will work but just won't load the next map). The name of the map should not include the ".bsp" extension. The "Landmark Name" value should be the name of...
  • An info_landmark. This should be somewhere in your safe room and be named uniquely. It should be in exactly the same relative position in the end safe room of the first map and the beginning safe room of the next map, as entities such as players and weapons will be teleported to their new positions relative to this landmark. ALWAYS align these things to the grid, it goes without saying.
  • A trigger_transition. This should fill the entirety of you safe room but ideally no more than this, since any entities inside its volume when the map changes will be teleported to their new positions in the next map relative to an info_landmark. The trigger_transition should be named the same as the info_landmark in your safe room, so that they work together.
  • A weapon_ammo_spawn. Once again, this is essential for computing the flow.
  • First aid kits and weapons of any kind are recommended.


The navigation mesh needs to be set up as follows:

  • The entirety of the nav in the safe room, up to and including the door mesh marked as DOOR, needs to be marked with the CHECKPOINT attribute. Any areas that you miss marking will allow zombies to spawn upon them; not too useful if you stagger into an end safe room feeling fairly pleased with yourself, then get pounced on by a Hunter who won't allow a map change until he's dead or out of the safe room.
Note.pngNote:nav_trouble_report checkpoint may assist in highlighting any nav areas you've missed marking.

Beginning Safe Room

This is the safe room at the beginning of the second map of a campaign onwards. You will need:

  • An info_player_start, placed slightly above the ground. This must be over the section of nav marked as CHECKPOINT (note that PLAYER_START is not required this time).
  • A weapon_ammo_spawn over the CHECKPOINT nav. Weapon and first aid kit spawns should be in pretty much the same places as they were in the previous safe room to maintain continuity. Note that if the map is loaded after a previous one is completed, on load the default weapons/ammo/first aid in the safe room will be deleted and the items from the previous safe rooms spawned in their relevant places. This ensures that there aren't duplicate spawns for items when the map loads.
  • An info_landmark placed in the same relative position as in the previous safe room.
  • A prop_door_rotating_checkpoint, recommended to be named "checkpoint_exit" (it "exits" the safe room).


The navigation mesh should be as follows:

  • The entirety of the mesh, up to and including the square marked with the DOOR attribute, should be marked as CHECKPOINT.
  • The EMPTY attribute should be used a little way after the exit door to ensure that zombies don't start off spawning too close.

Finale

A finale is the event at the end of the final map in a campaign. It should include:

  • A trigger_finale somewhere on the FINALE nav. This is essential to computing the flow. The trigger_finale doesn't necessarily have to be activated by the player; it can be activated via inputs from a func_button or the like but it does need to exist.
  • If a rescue vehicle is required, logic_relays will need to be activated at different stages by the trigger_finale to make events happen. This is generally beyond the scope of this article; see [link].


The navigation mesh should be set up as follows:

  • The FINALE attribute should be applied liberally to your finale area. Make sure it covers everything, even places where players can't get to but zombies can. Zombies are spawned upon the FINALE section of the mesh; breaks in it can cause problems. Use nav_trouble_report finale to highlight any bits you may have missed. As a note, when the survivors first "see"/walk over the finale mesh, one of them will call out "We're almost outta here!", or the equivalent.
  • If a rescue vehicle is used (theoretically the survivors could just run into a safe room that's unlocked at the end of the finale by the trigger_finale, although this wouldn't be very exciting), a nav_generate_incremental should be used to generate the nav at the point where the survivors stand inside the vehicle. These sectors should be marked with the RESCUE_VEHICLE attribute. Without this marking, the flow may not be computed correctly.

Rescue Closets

These are small rooms that dead survivors can be "rescued" from to allow them back into the game. As I have found out recently, the placing of rescue closets should follow some logic; there's no point putting one right next to the beginning/ending safe room (oops on both counts) as the survivors will respawn in these anyway. Rescue closets aren't required but do make game playing a little easier and also may aid in stopping nav_recompute_flow from complaining about "No rescue closets in finale".

The setup should be thus:

  • The room should be completely sealed off apart from one prop_door_rotating. This does not need to have any special properties apart from starting closed.
  • The closet should include three info_survivor_rescue entities, not four, as you won't be rescuing yourself. They should be placed slightly off the floor.


The navigation mesh should be marked appropriately by the nav_analyze phase.

Finally

  • If nav_trouble_report is highlighting all your nav sectors as "Missing Checkpoint", this means that either your beginning or end safe rooms aren't set up properly. Check through the list above.
  • If all else fails with nav editing, a full nav_generate can sort out any inobvious problems.

In Conclusion

If I've missed anything out of this list, feel free to tell me/add it in yourself; if you're having problems that you can't sort out, drop me an e-mail at jonathan[.]poncelet[@]talk21[.]com and I'll try to help. Happy mapping!