NPC Paths
An NPC Path spline is a path for NPCs to walk. You give it to an NPC Spawner as its Walk Path. The spawner's NPC walks to the path and along it. At stop points it stops, turns to look at the point and waits. You can make the NPC walk faster or slower on parts of the path.
Before you start
Rust does not read NPC paths by itself: a server needs the RustEdit 2 Server Extension to make the NPCs walk them.
How to make an NPC path
- Make a spline entity and draw the path. See Editing Splines.
- In the Inspector, click Path in the component buttons.
- In the Splines table, set the spline's Type to NPC Path.
- Click the row. Its Settings tab shows.
- Add stop points where the NPC should stop. See Stop points.
- Set how long the NPC waits at each stop point, in Stop 1, Stop 2 and so on.
- Select an NPC Spawner.
- Drag the spline entity from the Hierarchy onto the spawner's Walk Path in the Inspector. The spawner's NPC walks the path.
The Walk Path field takes a spline entity, and shows (Spline Entity) after its name. It takes only a spline entity with a spline of the NPC Path type. If you drop another object on it, the Notifications panel says why, and the Walk Path does not change.
- A spline entity with more than one NPC path shows a Spline list under the field. Pick the spline the NPC walks.
- To remove the path, right-click the field and click Clear. The NPC then roams.
- If you delete the path's spline entity, the field shows Missing path with a warning. An undo brings the path back.
Many spawners can walk the same path. While a spawner is selected, a dashed line goes from it to the point where its NPC joins the path.
Stop points
Stop points are places where the NPC stops and waits. The NPC walks to the point of the path nearest to the stop point. It turns to face the stop point and waits there for the stop point's wait time. Then it walks on.
Put a stop point beside the path, at the thing the NPC should look at, such as a campfire or a view. A stop point right on the path makes the NPC face along the path.
Stop points show as blue dots. A stop point more than 10 m from the path is red: move it closer. While the path is selected, each stop point shows its number and wait time, for example "Stop 1: 10 s".
| Button | What it does |
|---|---|
| Add Stop Point | Adds a stop point on the ground at the middle of the scene view. It waits 10 seconds. |
| Snap Stop Points | Moves every stop point onto the nearest point of the path. |
| Delete Selected Stop Points | Deletes the stop points you selected in spline edit mode. |
| Stop 1, Stop 2, ... | How long the NPC waits at each stop point, in seconds, 0 to 3600. The number is the one the scene view shows over the stop point. |
In spline edit mode, you can select and move stop points:
- Click a stop point to select it. Ctrl+Mouse Left adds more stop points to the selection.
- Drag a stop point to move it.
- Move the selected stop points with the transform gizmo, like knots. Selected knots move with them.
- Press Delete to delete the selected stop points, or click Delete Selected Stop Points.
Each of these changes is one undo step.
Speeds
A speed makes the NPC move at that speed on part of the path: faster, for example across a road, or slower, for example through a camp. You set it on a segment: the part of the path between two knots. A closed path also has the segment from its last knot to its first.
The speeds are Rust's own NPC speeds:
| Speed | What the NPC does |
|---|---|
| Own Speed | Moves at its own speed. This is the default. |
| Sneak | Sneaks, the slowest. |
| Walk | Walks. |
| Jog | Jogs. |
| Run | Runs. |
| Sprint | Sprints. |
| Full Sprint | Sprints as fast as it can. |
- Turn on spline edit mode.
- Click the path between two knots. The segment is selected. Ctrl+Mouse Left adds or takes out segments.
- In the spline widget, pick the speed in Speed.
You can also right-click a segment and pick the speed under Speed. A check mark shows the speed the segment has now.
Segments with a speed are drawn red (Sneak) to yellow (Full Sprint). While the path is selected, each one shows the name of its speed, for example "Run". Each change is one undo step. Speeds follow the knots like on an APC path: a knot put in on a segment keeps both halves at the speed.
Older versions saved NPC path speeds in meters a second. RustEdit cannot keep those speeds, so those segments open at Own Speed. Set them again.
At End
At End says what the NPC does at the end of an open path:
| Option | What it does |
|---|---|
| Walk Back | The NPC turns around and walks the path back to its start, then forward again. This is the default. |
| Start Again | The NPC walks from the end to the first point, then along the path again. |
| Stop | The NPC stays at the end. |
A closed path is a loop: the NPC walks around it. It has no At End.
What the export adds
When you export the map with In RustEdit data, RustEdit does not write the NPC paths into the map as splines. It writes them into its own data in the map, ready for the server to use. With In the map, the NPC paths and the spawners are lost. See In the map or in RustEdit data.
If a spawner's walk path is not in the scene any more, the export tells you: "... walks an NPC path the scene does not have". Its NPC does not walk a path on the server.
The scene file keeps the full splines. When you open an exported map without its scene, RustEdit makes the NPC paths again from their curves, with their stop points, speeds and At End. The spawners still walk them.
What the export writes for each NPC path
- The spline entity's number and name, and the spline's place in it. A spawner's Walk Path names its path by the same number and place.
- Nodes the same distance apart along the path, at most 5 m: the path's length is split into equal parts. On a segment whose two knots are on the ground or over it, a node under the ground goes up onto it. A node over the ground, for example on a floor or a bridge, keeps the spline's height.
- A segment with a knot more than 1 m under the ground keeps the spline's height, so NPCs can walk paths in tunnels, caves and bases under the terrain. Rust makes a navmesh there too.
- Each node is written with the segment it is on and its speed. The segments are written too, with their speed, their length and their nodes. A speed is written as Rust's NPC speed, or as Own Speed.
- Each stop point, with the point of the path the NPC stands on, the nearest node, the distance along the path and the wait time. Stop points are in order along the path.
- At End, whether the path is closed, and the spline's curves, for a server that wants to follow them smoothly.