The AI moves through the level on what’s called a Nav-Mesh. NPCs (Cops, AI Teammates, Civs) move according to it. The Nav-Mesh is split into “rooms”, the AI then navigates through the level by moving from room to room, attempting to complete their current set goal. They may be following a predetermined patrol path, walking up to the player to arrest them or moving to a set position to do some action.
The rooms that make up the mesh must be defined manually. Each room must have what's called a Navigation Segment placed inside. They are used to generate the Nav-Mesh.
To place Navigation Segments, go to the World Menu and into the AI-tab. There you will find the "Spawn Navigation Segment" button.
Navigation Segments will only be visible when inside this menu.
Next, we need to further define the Nav-Mesh using Blockers and Splitters. Both of these unit types are editor-only, meaning you have to enable the “Draw Editor Units” option to see them.
Splitters separate the rooms for navmesh generation. Each and every navigation segment has to be completely isolated from all other nav segments, and splitters are what do the job. When generating, solid objects block navigation so there is no need for placing them inside walls. These are used prominently in doorways or big open areas that you want to divide into smaller sections.
A single Splitter should never connect more than 2 Navigation Segments, otherwise the mesh will bleed when generating and not connect properly between segments.
Blockers prevent the Nav-Mesh from generating wherever you place them. Sometimes, a unit may have a slope that the generation perceives as space that should be traversable for NPCs. You also have to make sure navigation doesn’t seep out of the intended area and continue to generate near-infinitely on the background geometry.
You can find both Splitters and Blockers by looking for them in the Spawn Menu. Some names may be inconsistent, but they are colored in a specific way. Splitters are green and blockers are always red.
Cover Points, as the name suggests, are manually defined points in your level where the AI should take cover. Around props like barrels, pallets or cars, next to doorways or corners of buildings, basically everywhere where you think it makes sense. Coverpoints also play a big role in the movement of the NPCs, as they navigate from coverpoint to Coverpoint. If no Coverpoint is present, they will just move from segment to segment.
After generating your Nav-Mesh, you can view the results using the debug options in the AI-Tab. The most important are:
Quads show the Nav-Mesh as blue rectangles. Those are the areas your AI can technically move on. It May sometimes appear warped weirdly, especially at sloped areas and stairs, but it should still work fine when playing.
Coarse Graph shows you which segments are connected. If segments are connected with a thick yellow line, AI can freely move between them. Ideally, segments should only be connected with their neighbouring segments.
Covers show the location of cover points and what way they’re facing, the green line indicating the front. If the cone above them is green, they can be used by AI. If the cone is red, AI will not use them as they most likely are not on the Nav-Mesh, or the part they are placed on is disabled.
If you find issues with your mesh, for example it didn’t generate in specific areas you need it in, generated too much, or isn’t connecting certain parts properly, simply tweak the position of your blockers and splitters, and generate again until you’re happy with it.
Note: Navigation needs roughly 1.5m of free space above the segment to generate.
You can even generate individual segments by selecting them and clicking the Calculate Selected button in the AI-Tab, however before releasing the map you should re-generate your entire navigation with Calculate All to make sure there aren’t any potential issues with it.