Pathing
Enemies chasing the player, and villagers sent somewhere by a script, find their way around walls and props on their own. You don't write a line of code for it, and there is nothing to set up.
How it works
- Where things can stand is baked into a grid for each map from the props' collision and the ground.
- The straight line is tried first. A route is searched only when something is in the way, so open-ground chases cost nothing extra.
- A route is asked again only after a short wait and only when the target has really moved, so a crowd of enemies stays cheap.
- A target standing somewhere blocked (a doorway, against a wall) is approached at the nearest spot that can be reached, instead of the walker giving up.
- A walker pressed against the end of a wall still finds the way round it.
Side-view games keep the straight run: on a line there is nothing to walk around, and gravity owns the other axis.
The angled view is only a way of drawing the flat world, so one pathfinder serves top-down, side-on and angled games alike.
Crowds
Villagers don't have to stand still. A placed villager's Crowd section in Properties, or a whole Outliner folder's, says how they get about:
- Behaviour
- Wander about, stand Idle, Patrol, or Follow.
- Path
- Keep to one of the map's paths (below).
- Roam
- How far from home they wander.
- Walk speed
- As a percent of a normal walk.
- Pause from, Pause to
- How long they stop between walks, in seconds.
- Personal space
- How much room they keep from each other.
- Keep together
- They wander around the middle of all their homes, instead of each around its own.
A villager follows its folder's setting until you tick Own crowd settings on it.
Paths
A path is a line on the map that villagers walk along: a sidewalk, a market loop, the queue at a shop counter. Outliner > Add… > Path sets a two-point path across the middle of the view.
- Drag a point to move it. Drag off the line between two points to make a new point there, or Ctrl+click to add one after the last point you touched.
- Right-click a point to remove it. A path keeps at least two.
- Its Properties set the Shape and the Width of the lane walkers may use:
- Open
- Walked end to end and back.
- Loop
- The last point joins the first, and walkers go round.
- Queue
- Walked to the last point, the front of the line, where each walker waits behind the one ahead.
A trade route's caravan can walk a path too; see Maps and Travel.
If something will not path
The grid is built from collision. A prop with no collision is not an obstacle to the pathfinder or to anything else. A prop that blocks any kind of mover is treated as blocking for everyone when routes are planned.
Checking a route
Type engine path <x1> <y1> <x2> <y2> in the Rûn Console: it returns the route, the straight-line distance and the walked distance. A ratio near 1.00 means open ground; well above it means the route went around something.