S&box Wiki

Setting Up A Navigation Mesh

We advise against using this. It may be changed or removed in a future update.

What is a Navigation Mesh (Navmesh)?

A navigation mesh is a bunch of precalculated shapes compiled with a map that let NPCs and other entities navigate around.

How do I add one?

  1. In Hammer, in your map, create a func_nav_markup entity somewhere where you want the navmesh to be generated (it just has to be in a small part, it doesn't have to cover the entire area).
  1. On that entity, make sure Walkable Seed is ticked.

  2. Build your map with Build nav enabled, and you are done.

Navmesh Hulls

Navmesh hulls represent that fact that different NPCs might have different sized "hulls". Imagine a cat, a human and an elephant - they are all different sizes of creature and so are able to navigate different kinds of spaces.

You can configure the hulls in Hammer by going to Navigation and ticking Use Custom Generation Params, but you usually don't need to. The default hull used is hull 0 which is the medium-sized hull (for humans and such).

You can control which hull is used through code:

var path = NavMesh.PathBuilder( myStartPosition ) .WithAgentHull( NavAgentHull.Agent1 ) // The default is NavAgentHull.Default (hull 0). .Build( myEndPosition );

Nav Preview

Once you have added the func_nav_markup you can preview what your navigation mesh will look like in Hammer by going to Navigation -> Nav Preview.


The preview shows the passable space of each hull as a separate shade of blue.

Generally the preview should match how your navmesh behaves in-game, but if you are encountering problems, you can double-check by using the command nav_edit 1 in-game. You can then cycle through the different hulls by running nav_select_hull 0, nav_select_hull 1 and nav_select_hull 2.