This article relates to the game "Left 4 Dead". Click here for more information.
This article relates to the game "Left 4 Dead 2". Click here for more information.
This article's documentation is for anything that uses the Source engine. Click here for more information.

Sorting out navigation flow: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(-no)
 
(51 intermediate revisions by 10 users not shown)
Line 1: Line 1:
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.
{{lang|{{PAGENAME}}|title=Sorting out Navigation Flow}}{{l4ds topicons}}[[Category:Left 4 Dead]][[Category:Left 4 Dead 2]][[Category:Level Design]]
{{l4ds}} Getting the nav flow right can be one of the hardest parts in creating a good, working {{L4ds|3}} map. If the flow from the start to the end of the map is not valid, survivors may not be able to reach the end safe room or finale, rescue closets might not work and the wandering common 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.
Please feel free to add to this if you discover any other useful methods/pieces of information.


==Introduction==
== Introduction ==
Firstly, a standard ''Left 4 Dead'' campaign consists of at least two 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 map goes from safe room to safe room, or from safe room to finale ('''FINALE''') if it is the final map. You can have any number of maps you like in your campaign, but for a five-map campaign the general flow is as follows:


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''' - e.g., <code>l4d_airport01_greenhouse.bsp</code> - "Player Start" map.
* '''CHECKPOINT''' to '''CHECKPOINT''' - e.g., <code>l4d_airport02_offices.bsp</code> - "Checkpoint" map.
* '''CHECKPOINT''' to '''CHECKPOINT''' - e.g., <code>l4d_airport03_garage.bsp</code> - "Checkpoint" map.
* '''CHECKPOINT''' to '''CHECKPOINT''' - e.g., <code>l4d_airport04_terminal.bsp</code> - "Checkpoint" map.
* '''CHECKPOINT''' to '''FINALE''' - e.g., <code>l4d_airport05_runway.bsp</code> - "Finale" map.


* '''PLAYER START''' to '''CHECKPOINT''' - eg. ''l4d_airport01_greenhouse.bsp'' - "Player Start" map.
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 utilize a finale, and this just involves creating an ending safe room as usual but putting a dummy value in the {{ent|info_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 session will not finish correctly, since there will be an error in the console saying the next map cannot be found.
* '''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'''.
== Console Commands ==
To start editing the navigation mesh, type <code>exec [[Nav_mode.cfg|nav_mode]]</code> 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 {{key|PgDn}}.
{{note|This doesn't always seem to remove all editing functions, so you may need to type <code>exec config_default</code> afterwards to reset your controls to the default configuration.}}


{{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_position]]s 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.}}
The best way to get to know the commands is to open up the <code>nav_mode.cfg</code> file yourself and make a list of the keys; however, some very useful editing commands are below:
;<code>z_spawn</code> (default {{key|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, <code>z_spawn tank</code> will spawn a tank.
;<code>noclip</code> (default {{key|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.
;<code>nav_save</code> (default {{key|TAB}}):Saves your navigation mesh. ''Do this often,'' as there's no function for undoing changes if you mess things up!
;<code>director_start/stop</code> (default {{key|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.
;<code>respawn_bot</code> (default {{key|DEL}}):This respawns a random bot. Note that this is a custom alias created in the <code>nav_mode.cfg</code> file and so will not function unless you have exec'd the file. The alias <code>respawn_bots</code> respawns all four bots but is not bound to a key by default.
;<code>warp_all_survivors_here</code> (default {{key|'}}):Warps all survivors (including you) to the spot under your crosshair.
;<code>nb_delete_all</code> (default {{key|2}}):Deletes all NPCs (zombies, specials, survivors) from the world.
;<code>nb_move_to_cursor</code> (default {{key|3}}):Tells all NPCs to move towards the point under your crosshair. The target point is marked temporarily with a small green cross.
;<code>nav_simplify_selected</code> (default {{key|F7}}):Attempts to merge any nav areas you have selected to simplify them.{{warning|Don't try this with the whole map selected, as the game will crash.}}
;<code>nav_gui</code> (default {{key|F6}}):Opens up the nav-editing GUI with some advanced options.{{Note|The <code>nav_gui</code> command will need to be typed again to close the window and re-enable movement.}}
;<code>nav_trouble_report</code> (default {{key|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.


==Console Commands==
There are also some other very useful commands that are not included in the config:
;<code>z_show_flow_delta 1/2</code>: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).
;<code>z_show_flow_distance 1</code>:This enables the flow distance to be displayed: <code>xxxx/xxxx</code>. These numbers relate to the units increasing towards map goal/units increasing from start. If <code>-9999/-9999</code>, the flow to this nav area is broken.


To start editing the navigation mesh, type the following into the console:
==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.


* '''[[sv_cheats]] 1''' - Enables cheats.
If when running a map, you get a large "Map is unplayable!" error at the start, or a message in the chat indicating the Director can't spawn zombies, it's likely that your flow is broken. To fix this, one magic command can help tremendously in debugging: <code>nav_recompute_flow</code>. 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:
* '''director_stop''' - Disables zombie spawning - this can get annoying if you forget it.
;<code>GetGoalArea: Cannot find SPAWN_RESCUE_CLOSET area in FINALE, thus cannot guarantee reachability of goal area.</code>: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. {{ModernConfirm|Does this only apply to {{l4d}}?}}
* '''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.
: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.
* '''nav_edit 1''' - Allows nav mesh sectors to be modified.
;<code>ComputeFlowDistances: ERROR - [Error here]</code>:Depending on what error is being reported, this may be because of a number of problems:
* '''z_debug 1''' - Shows the attribute information regarding Left 4 Dead-specific properties.
:* <code>Cannot determine start/end area</code>: This means you have not set up your beginning/ending checkpoint or finale correctly. See the checklist below for more information.
:* <code>Cannot reach start area from end area</code>: 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 <code>nav_trouble_report orphan</code> to check for disconnected nav areas and <code>z_show_flow_distance/delta</code> to check the flow ID for each area. Look out for dark blue (one-way) connections which could be pointing ''backwards,'' i.e., 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|If you're having a problem where this error won't go away, there may be a checkpoint where you don't want one. An easy way to find the rogue area is to type <code>z_show_flow_distance 1</code> and look for any numbers that say either <code>xxxx/-9999</code> or <code>-9999/xxxx</code>. Follow these numbers in the direction that they decrease and you should find your unwanted checkpoint.}}
;<code>GetGoalArea: Cannot find end area - no checkpoint or finale located.</code>: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 checklist 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 add what will be needed eventually:


For issues regarding naigation flow you might also want to include:
=== Survivor Spawn Point===
This is the point at which the survivors originally spawn in the very first map of a campaign. Contrary to popular belief, there is only 1 unique entity that is required:
* Four {{ent|info_survivor_position}} entities, placed at least one unit above the ground. If you wish, you may also add a survivor name into the '''Survivor Name''' KeyValue.
==== Recommended entities ====
* An {{ent|info_player_start}}, placed at least 1 unit above the ground. This entity is only used if no info_survivor positions are in use '''AND''' when the navmesh hasn't been fully developed. In other words, only for dev purposes.
* Four {{ent|weapon_first_aid_kit_spawn}}s and low-powered weapon spawns ({{ent|weapon_smg_spawn}}, {{ent|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.


* '''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:


The navigation mesh must have the following:
* ''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 wandering 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.
Learn more about L4D(2) navmesh attributes [[List of L4D Series Nav Mesh Attributes|here.]]
===End Safe Room===
This is any safe room at the end of a map which leads onto the next map. You will need:
* A {{ent|prop_door_rotating_checkpoint}}. This is ''essential'' to the mechanics of a safe room and must ''not'' be a plain {{ent|prop_door_rotating}}. It is also recommended to set the keyvalue to start open (in whichever direction is most convenient).
* An {{ent|info_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 '''CHECKPOINT'''by the presence of this volume). The <code>New Map Name</code> 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 <code>.bsp</code> extension. The <code>Landmark Name</code> value should be the name of…
* An {{ent|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.
* First aid kits, ammo, and weapons of any kind (preferably lower tiers at first, then higher tiers) are recommended.
{{Tip|If you'd like to prevent witches from spawning in the safe room as well, mark every checkpoint nav square with the '''NOTHREAT''' attribute.}}


* '''GetGoalArea: Cannot find SPAWN_RESCUE_CLOSET area in FINALE, thus cannot guarantee reachability of goal area.'''
The navigation mesh needs to be set up as follows:
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).
* 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|<code>nav_trouble_report checkpoint</code> may assist in highlighting any nav areas you've missed marking.}}


* '''ComputeFlowDistances: ERROR - Cannot compute flow.'''
===Beginning Safe Room===
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.
This is the safe room at the beginning of the second map of a campaign onwards. You will need:


{{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.}}
* An {{ent|info_landmark}} placed in the same relative position as in the previous safe room.
* A {{ent|prop_door_rotating_checkpoint}}, with the model being the one with the bar.
:{{Note|Make sure the <code>Body</code> KeyValue is set to '''1''' to make sure the bar is actually visible.}}
==== Recommended Entities ====
* An {{ent|info_player_start}}, placed slightly above the ground. This must be over the section of nav marked as '''CHECKPOINT''' ('''PLAYER_START''' should not be used this time).
* A {{ent|weapon_ammo_spawn}}. 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|You don't have to be perfect about the positions of the item spawns; 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.}}


* '''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.


==Checklist==
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.


For me, this is my complete nav flow checklist:
=== Finale ===
A finale is the event at the end of the final map in a campaign. It should include:
* A {{ent|trigger_finale}} somewhere within the '''FINALE''' nav. This is needed to compute the flow, especially for a standard finale. Otherwise the furthest flow point will be the middle of the finale area. The <code>trigger_finale</code> doesn't necessarily have to interact with the player directly; it can be activated via inputs an entity such as a {{ent|func_button}}.
*{{l4d2}} Flow can also be manipulated with an {{ent|info_target}} with a special target name '''nav_flow_target'''. This especially useful for Gauntlet style finales but will result in the survivors gaining 100% score as soon as they reach it. Consider how it will effect Versus mode scoring when using this feature.
* If a rescue vehicle is required, take advantage of the outputs that will be fired at different stages by the <code>trigger_finale</code>. It will help synchronize major events during the finale. This is generally beyond the scope of this article. Please see [[L4D_Level_Design/Finale_Events_Part_1|Finale Events Part 1]] for more details.


* 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.
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 <code>nav_trouble_report finale</code> 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 similar.
* 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 <code>trigger_finale</code>, although this wouldn't be very exciting), a <code>nav_generate_incremental</code> 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.


* 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.
===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 gameplay a little easier and also may aid in stopping <code>nav_recompute_flow</code> from complaining about "No rescue closets in finale".


* 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.
The setup should be thus:
* The room should be completely sealed off apart from one {{ent|prop_door_rotating}}. This does not need to have any special properties apart from starting closed.
* The closet should include '''three''' {{ent|info_survivor_rescue}} entities, not four, as you won't be rescuing yourself. They should be placed slightly off the floor.


* 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.
The navigation mesh should be marked appropriately by the <code>nav_analyze</code> phase.


* 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.
=== Ladders ===
Ladders can be a non-obvious source causing a break in your flow. Although a ladder connected with <code>nav_build_ladder</code> may still work for path finding and climbing for NPCs and players, if the ladder is not tied to a <code>func_ladder</code>, the game cannot compute flow through them.
{{Note|If you run nav_analyze multiple times, ladders can go through some wear and tear to the point where survivor and infected bots have a lot of trouble trying to climb them. If this is ever the case, simply highlight the ladder, run the command <code>nav_delete</code>, and while still looking at the ladder, run the command <code>nav_build_ladder</code>, and make whatever other changes you want to the navmesh, then analyze the navmesh again.}}


==In Conclusion==
* Make sure all ladders are tied to a {{ent|func_ladder}}. Use <code>nav_trouble_report</code> to find ladders which are not. It will report the assigned numerical name to them. Use <code>nav_edit 1</code> and <code>z_debug 1</code> and point at ladders in-game to see their assigned numbers.


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!
=== Miscellaneous ===
* If <code>nav_trouble_report</code> 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 <code>nav_generate</code> can sort out any non-obvious problems. Or, you can always consult the Left 4 Dead 2 modding forums on Steam.
 
== Elevators ==
A [[L4D Level Design/Elevators|basic elevator]] can start on the bottom or top of the floors available. It is recommended that flow/escape route is already established from starting point to the goal area before setting elevators. This can be done by adding a temporary path to test with, such as adding a temporary ladder for survivors.
 
If adding an elevator and removing the temporary ladder breaks the flow that was known to work before, consider the following:
*Make sure there are two {{ent|info_elevator_floor}} entities for your elevator that are centered, and that there is a nav mesh for each floor. '''The<code>info_elevator_floor entities</code>will not work properly unless they are level with the floor.''' When your elevator is properly connected you will see 4 green tracelines from each corner of the nav mesh with <code>nav_edit 1</code> and <code>z_debug 1</code>. If you see these green tracelines and Survivor Bots follow you into the elevator, but your flow is still broken, it means you have a flow break somewhere else in your map.
*Simplify the nav area that is covering the elevator floor. There should be a single nav area covering the entire floor.
*<code>ESCAPE_ROUTE</code> should reach the elevator floor nav area. If there is a small nav area touching the elevator floor, the <code>ESCAPE_ROUTE</code> will stop there on that particular floor and can cause problems with bots on other floors. Delete the small nav areas touching the elevator and reestablish all appropriate connections.
*Make sure the elevator nav areas on each floor are the same size and parallel to each other. In [[nav_mode.cfg (L4D)|nav mode]] and with <code>nav_snap_to_grid</code> turned on: create the nav area of the same size with the elevator floor, raise the unconnected copy above the next floor, move the elevator to the next floor, and finally place the nav area on ground. Delete an extraneous nav areas and establish appropriate connections.{{todo|confirm claims made by this bullet point. needs pictures!}}
*The func_elevator brush must be the thing that survivors stand on when using the elevator. Its collision cannot be covered up by anything, not props or func_brushes. In other words, the func_elevator must be exposed, and the object that survivors stand on inside the elevator. Not doing so will cause shaky camera movement, and bots will not pile into the elevator. If you're using the elevator model from Hard Rain, for example, just texture the func_elevator brush with <code>toolsnodraw</code>, do not hide the func_elevator brush underneath the elevator model.
*{{ent|info_changelevel}} should point to a non-empty map name. An actual map name is recommended.
*<code>info_changelevel</code>should point to a non-empty landmark. An actual landmark within the map is recommended.
 
This results in correct nav flow to the goal area and proper bot behavior on an arbitrary number of floors.
{{tip|Valve provides an example map, <code>deadline02</code>, with a basic elevator. Try breaking and restoring the flow on the map while in nav mode.}}
=== Notes About Elevators ===
The nav mesh must flow seamlessly throughout a level, but what happens when you add elevators? Nav sectors ''seem'' to not connect vertically down elevator shafts, at least visually, but they will connect properly, generate the desired flow/<code>ESCAPE_ROUTE</code>, when the criteria are met. It may start working as the campaign reaches completion, but that is most likely an unacceptable answer!
 
Whereas conventional elevators are made using entities like {{ent|func_door}} or {{ent|func_movelinear}} (for two-stop elevators) and {{ent|func_tracktrain}} (for elevators with 3+ stops), ''Left 4 Dead'' uses a bespoke entity for this purpose called {{ent|func_elevator}}. This article does not cover the construction of elevators; please see the [[Elevators]] article for details.
 
Getting an elevator to work with bots and maintaining a proper flow can become frustrating. This has resulted in a some creative workarounds:
*Create a large elevator in order to coax the bots into following you in to at least the front
*Create a "backdoor" where the flow is going through a ladder hidden in the elevator shaft
*Start at the top position only
*Add the '''BATTLESTATION''' attribute to the nav area covering the elevator floors
*nav_connect, nav_splice, nav_split nav area floors together, near or on the elevator
*Add a giant trigger_push or teleport to force survivor bots into the elevator
*Creating nav areas between floors if elevator moves on a slope
 
These workarounds may or may not work to various degrees and may depend on the situation. In official maps, the situation is always simple and consistent: two floors, in sealed container, moving either up or down the elevator vertically, and towards a goal. None of the workarounds listed were needed in that situation. In more complicated situations, however, these workarounds may offer a solution.

Latest revision as of 22:27, 9 February 2024

English (en)Translate (Translate)

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

Please feel free to add to this if you discover any other useful methods/pieces of information.

Introduction

Firstly, a standard Left 4 Dead campaign consists of at least two 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 map goes from safe room to safe room, or from safe room to finale (FINALE) if it is the final map. You can have any number of maps you like in your campaign, but for a five-map campaign the general flow is as follows:

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

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 utilize a finale, and this just involves creating an ending safe room as usual but putting a dummy value in the info_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 session will not finish correctly, since there will be an error in the console saying the next map cannot be found.

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 PgDn.

Note.pngNote: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 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 ')
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.
Warning.pngWarning: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.pngNote: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, or a message in the chat indicating the Director can't spawn zombies, 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.
Confirm:Does this only apply to Left 4 Dead?
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, i.e., 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:If you're having a problem where this error won't go away, there may be a checkpoint where you don't want one. 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 checklist 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 add what will be needed eventually:

Survivor Spawn Point

This is the point at which the survivors originally spawn in the very first map of a campaign. Contrary to popular belief, there is only 1 unique entity that is required:

  • Four info_survivor_position entities, placed at least one unit above the ground. If you wish, you may also add a survivor name into the Survivor Name KeyValue.

Recommended entities

  • An info_player_start, placed at least 1 unit above the ground. This entity is only used if no info_survivor positions are in use AND when the navmesh hasn't been fully developed. In other words, only for dev purposes.
  • 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 have the following:

  • 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 wandering 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.

Learn more about L4D(2) navmesh attributes here.

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 recommended to set the keyvalue to start open (in whichever direction is most convenient).
  • An info_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.
  • First aid kits, ammo, and weapons of any kind (preferably lower tiers at first, then higher tiers) are recommended.
Tip.pngTip:If you'd like to prevent witches from spawning in the safe room as well, mark every checkpoint nav square with the NOTHREAT attribute.

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:

Note.pngNote:Make sure the Body KeyValue is set to 1 to make sure the bar is actually visible.

Recommended Entities

  • An info_player_start, placed slightly above the ground. This must be over the section of nav marked as CHECKPOINT (PLAYER_START should not be used this time).
  • A weapon_ammo_spawn. 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.pngNote:You don't have to be perfect about the positions of the item spawns; 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.


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 within the FINALE nav. This is needed to compute the flow, especially for a standard finale. Otherwise the furthest flow point will be the middle of the finale area. The trigger_finale doesn't necessarily have to interact with the player directly; it can be activated via inputs an entity such as a func_button.
  • Left 4 Dead 2 Flow can also be manipulated with an info_target with a special target name nav_flow_target. This especially useful for Gauntlet style finales but will result in the survivors gaining 100% score as soon as they reach it. Consider how it will effect Versus mode scoring when using this feature.
  • If a rescue vehicle is required, take advantage of the outputs that will be fired at different stages by the trigger_finale. It will help synchronize major events during the finale. This is generally beyond the scope of this article. Please see Finale Events Part 1 for more details.


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 similar.
  • 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 gameplay 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.

Ladders

Ladders can be a non-obvious source causing a break in your flow. Although a ladder connected with nav_build_ladder may still work for path finding and climbing for NPCs and players, if the ladder is not tied to a func_ladder, the game cannot compute flow through them.

Note.pngNote:If you run nav_analyze multiple times, ladders can go through some wear and tear to the point where survivor and infected bots have a lot of trouble trying to climb them. If this is ever the case, simply highlight the ladder, run the command nav_delete, and while still looking at the ladder, run the command nav_build_ladder, and make whatever other changes you want to the navmesh, then analyze the navmesh again.
  • Make sure all ladders are tied to a func_ladder. Use nav_trouble_report to find ladders which are not. It will report the assigned numerical name to them. Use nav_edit 1 and z_debug 1 and point at ladders in-game to see their assigned numbers.

Miscellaneous

  • 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 non-obvious problems. Or, you can always consult the Left 4 Dead 2 modding forums on Steam.

Elevators

A basic elevator can start on the bottom or top of the floors available. It is recommended that flow/escape route is already established from starting point to the goal area before setting elevators. This can be done by adding a temporary path to test with, such as adding a temporary ladder for survivors.

If adding an elevator and removing the temporary ladder breaks the flow that was known to work before, consider the following:

  • Make sure there are two info_elevator_floor entities for your elevator that are centered, and that there is a nav mesh for each floor. Theinfo_elevator_floor entitieswill not work properly unless they are level with the floor. When your elevator is properly connected you will see 4 green tracelines from each corner of the nav mesh with nav_edit 1 and z_debug 1. If you see these green tracelines and Survivor Bots follow you into the elevator, but your flow is still broken, it means you have a flow break somewhere else in your map.
  • Simplify the nav area that is covering the elevator floor. There should be a single nav area covering the entire floor.
  • ESCAPE_ROUTE should reach the elevator floor nav area. If there is a small nav area touching the elevator floor, the ESCAPE_ROUTE will stop there on that particular floor and can cause problems with bots on other floors. Delete the small nav areas touching the elevator and reestablish all appropriate connections.
  • Make sure the elevator nav areas on each floor are the same size and parallel to each other. In nav mode and with nav_snap_to_grid turned on: create the nav area of the same size with the elevator floor, raise the unconnected copy above the next floor, move the elevator to the next floor, and finally place the nav area on ground. Delete an extraneous nav areas and establish appropriate connections.
    Todo: confirm claims made by this bullet point. needs pictures!
  • The func_elevator brush must be the thing that survivors stand on when using the elevator. Its collision cannot be covered up by anything, not props or func_brushes. In other words, the func_elevator must be exposed, and the object that survivors stand on inside the elevator. Not doing so will cause shaky camera movement, and bots will not pile into the elevator. If you're using the elevator model from Hard Rain, for example, just texture the func_elevator brush with toolsnodraw, do not hide the func_elevator brush underneath the elevator model.
  • info_changelevel should point to a non-empty map name. An actual map name is recommended.
  • info_changelevelshould point to a non-empty landmark. An actual landmark within the map is recommended.

This results in correct nav flow to the goal area and proper bot behavior on an arbitrary number of floors.

Tip.pngTip:Valve provides an example map, deadline02, with a basic elevator. Try breaking and restoring the flow on the map while in nav mode.

Notes About Elevators

The nav mesh must flow seamlessly throughout a level, but what happens when you add elevators? Nav sectors seem to not connect vertically down elevator shafts, at least visually, but they will connect properly, generate the desired flow/ESCAPE_ROUTE, when the criteria are met. It may start working as the campaign reaches completion, but that is most likely an unacceptable answer!

Whereas conventional elevators are made using entities like func_door or func_movelinear (for two-stop elevators) and func_tracktrain (for elevators with 3+ stops), Left 4 Dead uses a bespoke entity for this purpose called func_elevator. This article does not cover the construction of elevators; please see the Elevators article for details.

Getting an elevator to work with bots and maintaining a proper flow can become frustrating. This has resulted in a some creative workarounds:

  • Create a large elevator in order to coax the bots into following you in to at least the front
  • Create a "backdoor" where the flow is going through a ladder hidden in the elevator shaft
  • Start at the top position only
  • Add the BATTLESTATION attribute to the nav area covering the elevator floors
  • nav_connect, nav_splice, nav_split nav area floors together, near or on the elevator
  • Add a giant trigger_push or teleport to force survivor bots into the elevator
  • Creating nav areas between floors if elevator moves on a slope

These workarounds may or may not work to various degrees and may depend on the situation. In official maps, the situation is always simple and consistent: two floors, in sealed container, moving either up or down the elevator vertically, and towards a goal. None of the workarounds listed were needed in that situation. In more complicated situations, however, these workarounds may offer a solution.