Skip to content

GridPatrol

Walks its GridMovement round a route of cells with no code: guards, villagers, a maze’s sentries, a block that slides back and forth. Points are steps from where it’s placed, e.g. “4 0” (four cells right and back) or “4 0; 4 -3; 0 -3” (round a square). It finds its way around walls between them, waits for whatever stands in its way, and pauses Wait seconds at each. With a GridChase too, it walks its route until it spots the target. The Scene view draws its route, with knobs to drag its points from cell to cell.

Requires: GridMovement

Works with: GridChase (walks its route until it spots its target)

Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.

  • points: text = “4 0”. Where to go, in cells from where it’s placed (x right, y up): “x y” pairs separated by semicolons, e.g. “4 0” or “4 0; 4 -3; 0 -3”. The start (0 0) is always the first point. On a hex map they’re columns and rows, so “0 2” is straight up the screen and “0 1” the row above, half a hexagon to one side. (Points: “x y” pairs separated by semicolons, e.g. “4 0; 4 3”, in whole cells; the start (0 0) is always the first point and isn’t listed; at least 1. The Inspector lists them a row each to set, add, remove and reorder.) (Field: its own editor: Points.)
  • mode: one of PingPong, Loop, Once = “PingPong”. How it goes round its points: there and back, round in a loop, or once. (Field: one of its values.)
  • wait: a number = 0.5. Seconds to wait at each point. Taking turns (a TurnTaker with actions), it waits that many of its turns instead, rounded up. (Field: a number.)
  • running: true or false = true. Untick it to stop it where it is. Switches tick and untick it. (Field: on or off.)
  • leg: a whole number = 0. Which stretch of its route it’s walking, from 0 (the start to the first point). The game keeps it up to date; set it to start part of the way round, so a row of guards don’t all walk together. (Field: a number.)
  • away: [x, y] = [0,0]. How many cells from where it was placed it is (x right, y up), which its points are counted from. The game keeps it up to date as it steps or is moved, so one chased or pushed off its route finds its way back. (Field: a vector.)

Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.

  • isFinished: true or false. True once a MoverMode.Once patrol has reached its last point.
  • lastCell: [x, y], whole numbers or null. The cell it was in last frame, to add how far it went to Away. Not saved: a restored game starts counting again from wherever it is.
  • waitLeft: a number. Seconds left waiting at a point.

Scripts use it as GridPatrol: its methods, events and values that aren’t saved with the scene.