Tutorial / Tools > AI

AI Paths

Give one NPC its own path, with things to do at points.

What it does

AI Paths gives a single NPC its own path. You pick the NPC, click points on the ground, and start it. At each point it can wait, face a direction, open a door, press a button or say a line.

The path can loop, go back and forth, or run once and stop at the end. You can also save the path as a Patrol & Guard route that other NPCs can walk.

The panel also shows the map's nav mesh status. Superadmins can generate the nav mesh from here. With a nav mesh, NPCs walk their orders and paths along it, so they find their way on maps without AI nodes.

Where to find it

Q menu > KGX's Admin Toolbox > AI > AI Paths.

Admins can use it. Other players can use it only if they are given the tool in Settings > Player Access. Generating the nav mesh is for superadmins only.

Admins only (v3.6.11.3): this tool sets up the server, so it cannot be given to players; it is greyed out in Settings > Player Access.

Controls

Key What it does
Left click Add a point to the picked NPC's path, with the panel's point settings
Right click Pick the aimed NPC
Reload Take the last point away

Options

Point settings

These go with each new point when you left click.

Option What it does Default
Wait at the point (seconds) How long the NPC waits there (0-120) 0
Run to the point The NPC runs to this point Off
At the point Just walk on, Face the way I looked, Open the door close by, Press the button close by, Say the text below Just walk on
Text to say The line for Say the text below (up to 120 characters) Empty
Path
Option What it does
Path Round and round (loop), Back and forth, or Once, then stay. Applies to the picked NPC at once.
Start walking the path The NPC starts at its nearest point and walks the path
Stop (free again) Removes the order; the NPC goes back to its own AI
Clear the path Deletes every point and stops it
Save it as a route (AI > Patrol & Guard) Asks for a name and saves the points as a patrol route
Nav mesh
Option What it does
Nav mesh: Status: none, generating, loaded (with the number of areas), or unavailable
Generate the nav mesh (superadmins) Generates the nav mesh for this map after a confirmation. Shown to superadmins only.
Refresh Updates the status

How to use it

Give an NPC a walking route
  1. Aim at the NPC and right click to pick it. The HUD shows its name and point count.
  2. Set the point settings, then left click the ground for each point in order.
  3. Pick a Path mode and click Start walking the path.
Make an NPC greet people at a door
  1. Pick the NPC with right click.
  2. Set Wait at the point (seconds) to 5, At the point to Say the text below, and type the line in Text to say.
  3. Left click near the door. Add a second point elsewhere with Just walk on.
  4. Click Start walking the path. The NPC shows the line in a speech bubble at the first point.
Turn a path into a shared route
  1. Make a path with at least 2 points.
  2. Click Save it as a route (AI > Patrol & Guard) and type a name.
  3. The route is listed in Patrol & Guard, saved for the map.
Generate the nav mesh
  1. As a superadmin, stand somewhere players can walk.
  2. Click Generate the nav mesh (superadmins) and confirm with Generate.
  3. Wait. The server freezes for seconds to minutes, and the map may reload when it is done.

Settings and commands

Setting What it does Default
kgxat_ai_navmesh 1 = with a nav mesh on the map, NPCs walk their orders along it 1
kgxat_ai_unstuck 1 = NPCs stuck while walking try another way 1

Both are in AI > AI Brain.

Tips and limits

  • At most 64 points per path. The path belongs to that NPC and is not saved to a file. Save it as a route to keep it for the map.
  • Face the way I looked uses the direction you were looking when you clicked the point.
  • Open the door close by opens an unlocked door within 140 units. Press the button close by presses a button within 110 units.
  • Run points are drawn orange; other points yellow. Points show only while you hold the tool.
  • A saved route takes its run and wait from the first point. Back and forth saves as a back-and-forth route; the other modes save as a loop.
  • An NPC in a fight fights first, then carries on with the path.
  • While the nav mesh is generated, everyone's cl_timeout and the server's sv_timeout are raised to 900 seconds and put back afterwards. A banner tells players to stay connected.
  • On big maps the surest way is to generate with nobody else on the server, or in your own singleplayer game on the same map, then upload garrysmod/maps/<map>.nav to the server's maps folder.
  • The nav mesh is generated once per map and saved with it (maps/<map>.nav).
  • To see where every NPC walks, use AI > AI Brain > Draw NPC paths, nav mesh legs, job targets and enemies (admins).

Back to Tools

Type to search every tool, panel, setting, FAQ answer and release.