Skip to content

Tutorials · Navigation and AI · Chapter 4

Shortcuts

15 minutes Uses: NavLink

By the end

  • A Nav Link on hole that drops from the store room to the cellar, one way and at once, at half the price of walking as far
  • A Nav Link on ladder between the corridor and the gallery, climbed both ways at three times the price
  • A Nav Link on hatch from the cellar to the courtyard, switched off: drawn dashed and crossed
On this page

The cellar hole

Chapter 2 left the cellar and the gallery as islands: floor on the map, but no floor joining them to the rest. A wall stays a wall. What crosses it is a Nav Link: a line from one point to another that a walker may take where no floor joins them. The keep has three, each on the picture it stands for, which came with the starter: the hole in the store room’s floor, the ladder down from the corridor, and the hatch in the cellar.

The hole is a way down. A walker in the store room may drop through it and land in the cellar, at once, and there is no climbing back.

  1. Select hole in the Hierarchy: the dark hole near the store room’s south wall. Click Add component and choose NavLinkComponent.
  2. From stays 0, 0: the hole’s own middle. Set To: click its x box once, so that its number is selected, type -480 and press Enter; then click its y box once, type 160 and press Enter. That is 480 to the left and 160 down from the hole: the middle of the cellar.
  3. Set Cost to 0.5 the same way, and tick Teleport. Both Ways stays unticked and Enabled stays ticked.
hole selected, its Inspector narrowed with the search box, link, to its Nav Link: From 0.0 and 0.0, To -480.0 and 160.0, Both Ways unticked, Enabled ticked, Cost 0.50, Teleport ticked; in the Viewport a pale blue line runs from the hole in the store room down to the left, across the corridor, to a small square handle in the cellar
The hole’s link: from the hole to its To in the cellar. The pictures in this chapter draw the Navigation gizmos only, and use the select tool, the arrow just before the Move tool in the toolbar, so that the Move tool’s arrows do not hide a link’s line.
From
The Nav Link’s From: where it starts, in world units, measured from its node, so the link moves with the node. A new link’s is 0, 0, the node itself, and the hole keeps it: a walker on the hole’s floor is at the start of the link. The map joins the floor cell under each end; an end that falls on a wall is joined to the nearest floor within two cells.
To
The Nav Link’s To: where it ends, in world units from its node, as From is. A one-way link goes from From to To and never back. The hole’s -480, 160 reaches from the store room to the cellar’s middle. A new link’s is 0, -64, four tiles up.
Cost
The Nav Link’s Cost: how many times dearer crossing it is than walking as far. Under 1 it is a shortcut, over 1 a way taken only when the floor is dearer still. The hole’s 0.5 makes a drop of about 506 units cost what 253 units of floor cost. A new link’s is 1; it cannot go under 0.
Teleport
The Nav Link’s Teleport: ticked, a walker that reaches From is put at To in one step, as a drop is; unticked, it is carried along the line from end to end at the walker’s own speed, as a climb is. A new link’s is unticked. The hole ticks it: a cat does not float down through the corridor.

The ladder

The ladder hangs from the corridor’s floor down into the gallery. Unlike the hole it goes both ways, and climbing it is slow: it costs three times what walking as far costs.

  1. Select ladder in the Hierarchy. Click Add component and choose NavLinkComponent.
  2. Set From to 0, -24, clicking each box once, typing and pressing Enter: the ladder’s top, on the corridor’s floor. Set To to 0, 48: past its foot, on the gallery’s floor.
  3. Tick Both Ways, and set Cost to 3. Teleport stays unticked and Enabled stays ticked.
ladder selected, its Inspector narrowed to its Nav Link: From 0.0 and -24.0, To 0.0 and 48.0, Both Ways ticked, Enabled ticked, Cost 3.00, Teleport unticked; in the Viewport a short pale blue line runs down the ladder from a handle on the corridor’s carpet to a handle on the gallery’s floor
The ladder’s link: from the corridor down to the gallery, both ways.
Both Ways
The Nav Link’s Both Ways: ticked, a walker may also cross it from To back to From, at the same price. The ladder ticks it, so the gallery can be left as it was reached. A new link’s is unticked: one way, as the hole is. Drawn unselected, a link has an arrowhead at each end it can be crossed to.

The shut hatch

The hatch in the cellar comes up in the courtyard. It is shut, and stays shut: a link switched off is still drawn, so you can see where it would go, but no way uses it.

  1. Select hatch in the Hierarchy: the grate in the cellar. Click Add component and choose NavLinkComponent.
  2. From stays 0, 0. Set To to 232, 0: across to the courtyard’s west end.
  3. Untick Enabled, and tick Teleport. Cost stays 1 and Both Ways stays unticked.
  4. Press Ctrl+S.
hatch selected, its Inspector narrowed to its Nav Link: From 0.0 and 0.0, To 232.0 and 0.0, Both Ways unticked, Enabled unticked, Cost 1.00, Teleport ticked; in the Viewport a dashed pale blue line runs east from the grate in the cellar, across the gallery, to a handle at the courtyard’s west edge, with an X at its middle
The hatch: switched off, so its line is dashed and crossed with an X.
Enabled
The Nav Link’s Enabled: whether a way may use it right now. Unticked, the map leaves it out and the Viewport draws it dashed, with an X at its middle. A new link’s is ticked, and the hole and the ladder keep it so.

What the map offers now

Nothing walks yet, so what the links change is what the map offers. From the store room, the way to the cellar drops through the hole, at once. From the cellar there is no way out: the hole goes one way and the hatch is shut. The corridor and the gallery are joined by the ladder, down and up, as far each way. A walker that may not take links, as the corridor guard will be in chapter 6, finds no way to the gallery at all.

The first walker comes in Walking it: the cat, which you send down the hole in Play and watch its route cross to the cellar.

The three links

NodeComponentFieldValue
holeNav LinkTo-480, 160
Cost0.5
Teleportticked
ladderNav LinkFrom0, -24
To0, 48
Both Waysticked
Cost3
hatchNav LinkTo232, 0
Enabledunticked
Teleportticked

Every other field is as it comes: the hole’s and the hatch’s From 0, 0, the hatch’s Cost 1.

Check it works