Difference between revisions of "Sorting out navigation flow"

From Valve Developer Community
Jump to: navigation, search
Line 67: Line 67:
If anyone's having problems they can't sort out, drop me an e-mail at '''jonathan[.]poncelet[@]talk21[.]com''' and I'll try to help. Happy mapping!
If anyone's having problems they can't sort out, drop me an e-mail at '''jonathan[.]poncelet[@]talk21[.]com''' and I'll try to help. Happy mapping!
[[Category:Left 4 Dead]]

Revision as of 08:11, 8 November 2009

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.


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: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 the following into the console:

  • sv_cheats 1 - Enables cheats.
  • director_stop - Disables zombie spawning - this can get annoying if you forget it.
  • nb_delete_all - This removes the survivors and all zombies. If you want to test the navigation mesh by walking through the map with the survivor bots, leave this command out.
  • nav_edit 1 - Allows nav mesh sectors to be modified.
  • z_debug 1 - Shows the attribute information regarding Left 4 Dead-specific properties.

For issues regarding naigation flow you might also want to include:

  • 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 decreasing towards the end/units increasing from start. If -9999/-9999, the flow to this nav area is broken.
  • nav_recompute_flow - This is your best friend. If you type this into the console, the game will attempt to recompute the navigation flow of the map. If there's no errors, you're fine - if there are errors, they are usually one of the following three:

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

This means: either you have not inserted a survivor closet into your finale map (see fourth section of checklist below) or the game has not detected two distinct CHECKPOINT areas (see 5th section of checklist below).

  • ComputeFlowDistances: ERROR - Cannot compute flow.

This means that your navigation flow is broken somewhere - there are nav sectors that are not connected to each other and so do not complete the flow from the beginning to the end of the map. Nav_trouble_report orphan will usually highlight where the break is - if not, manually check through your intended route for any vital connections that are missing. Left 4 Dead commonly mucks up stair meshes - these would be your first suspects.

Note: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.


For me, this is my complete nav flow checklist:

  • If on Player Start map (see top) of campaign, needs a PLAYER START nav surrounded by CHECKPOINT where the players will spawn. If not starting map (a Checkpoint or Finale map, see top), just needs CHECKPOINT areas inside the safe room.
  • Prop_door_rotating_checkpoint in the spawning safe room needs to be named checkpoint_exit, and in the final safe room named checkpoint_entrance. These names are important: I have unconfirmed speculations, but I think that the navigation flow is invalid if these names are not followed correctly. They 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 needs to be put into the ending saferoom and needs to touch at least the majority of floor space in the room. This is so that, when computing the navigation mesh, the game knows where to mark the CHECKPOINT areas. Note that the trigger_changelevel does not necessarily need to point to a valid map but does need to have something in the map field, otherwise the navigation flow may not be computed correctly. Should usually be used in conjuction with a trigger_transition and info_landmark, named identically to each other.
  • After recent investigation, I've found out that the placement of weapons and items is important when computing navigation flow. The game uses these entities to further help distinguish safe rooms from the rest of the map. It's recommended to have at least one weapon_ammo_spawn, four weapon_first_aid_kit_spawns and either a Pump Shotgun and SMG or the three power weapons in each safe room or starting area.
  • It is recommended that each map has at least one survivor closet: a room, completely sealed apart from a prop_door_rotating, and housing three info_survivor_rescue entities. Note that PLAYER START to CHECKPOINT (Player start) or CHECKPOINT to CHECKPOINT (Checkpoint) maps don't necessarily need one, as the safe room acts as a closet on the next map load [can someone confirm this?]. However, for finale maps it is essential that a survivor closet exists, since there is no final saferoom for the survivors. If you do not put a survivor closet in a finale map, there will be an error when computing the flow - see the first nav_recompute_flow error above.
  • If all the navigation sectors in your map are marked "Missing Checkpoint" by nav_trouble_report checkpoint, this is either because you haven't set up one/both of your checkpoints properly, or because some areas of navigation mesh are either preceding your first checkpoint or succeeding your last checkpoint. If there are nav areas beyond either of these checkpoints, the safe room areas are not going to be marked explicitly as the beginning and ending areas of your map - for example, if there was some mesh succeeding your ending safe room, the end of this extra mesh area would become the end of the map and the safe room area would only be 99% of the way there, which is not what we would want. Since the nav generation process sometimes isn't the smartest, it'll think that all the mesh in-between your beginning and ending safe rooms should belong to one safe room only - the one at the start. Hence, it wants you to have a massive safe room spanning the entirety of your map, just to have the actual playable section as that tiny, unmarked bit right at the end. Luckily, if you delete these extra areas the problem should go away. Correct me if I'm wrong, of course.
  • Finally, if all else fails, re-generate your mesh using nav_generate and tweak it to your liking. This sometimes solves problems that you cannot find a solution to.

In Conclusion

If anyone's having problems they can't sort out, drop me an e-mail at jonathan[.]poncelet[@]talk21[.]com and I'll try to help. Happy mapping!