Skip to content

Maze chaser

For creatorsAdd-on 2.2.2+

In this tutorial you build a maze game. A runner eats every spark in a maze while four chasers hunt it; a core scares them for a few seconds, and then the runner can eat them. Three things are new: the level is painted in Blender and baked to data, actors glide from cell to cell, and four chasers with four personalities come from one rule aimed at four different targets. This builds on tutorial 8, Star swarm.

▶ Play the finished game: arrows or W A S D steer (the runner turns as soon as the way you asked is open), Enter plays again. On a phone, tap ◀ ▲ ▼ ▶.

  1. Save a new file as maze-tiles.blend and model six tiles for a 1-metre cell, each tagged with tile.value and tile.name as in tutorial 5: floor 1, wall 2, spark 3, core 4, the house door 5, the house floor 6.

  2. Press Build Cartridge.

The dungeon generated its levels; this maze is drawn, the way a level designer works. The objects are the source and the data is the output.

  1. In a new file, maze-chaser.blend, add an Empty named Level. In Object Properties ▸ Custom Properties, give it level = 1 and level.size = 21,21. Add level.marks = start,exit,home to make those marks required.

  2. Copy the tile models into the file and stand copies of them on the cells under Level: parent each one to it (Ctrl P) and give it the custom property cell.value with its tile’s value. Cells you leave empty are 0.

  3. Add marker Empties under Level, each with the custom property level.mark: start (where the runner starts), exit (where the house door opens) and home (where eyes go back to). Marks named with a number at the end, sentry0 to sentry3, also become lists in that order: the chasers’ starting places.

  4. Give Level and everything under it the custom property sim.source = 1. The .blend keeps them; the published world never receives them.

  5. Press Bake in World ▸ Simulacrum ▸ Levels, or Bake Levels in the 3D Viewport’s header. It checks the level and writes it as a data table.

Tag On Value What it does
level the level Empty 1 Marks a painted level
level.size the level Empty 21,21 Its width and height in cells
level.cell the level Empty 1 (default) Metres per cell
level.marks the level Empty start,exit,home Marks the bake requires
level.data the level Empty data/level.json (default) The table the bake writes
level.index the level Empty 0, 1, … The level’s row when several levels share one table
cell.value each tile copy the tile’s value What its cell holds
level.mark each marker Empty a name A named cell: the row gets its x and y

Set these as custom properties with exactly these names, or add them with Add Tag in Object ▸ Simulacrum ▸ Tags; the bake reads either.

What the bake does. Each object’s cell comes from where it stands: cell (0, 0) is at the Level Empty, columns run along Blender’s X and rows along minus Blender’s Y, one level.cell apart. Its value comes from its tag. The result is one row of data/level.json: the grid, each mark as startX and startY, and numbered marks as lists. Errors stop it: two objects on one cell, an object outside the level, or a required mark missing. A model standing off its cell’s centre gets a warning. Build Cartridge bakes again every time, so what ships always matches what you painted. Paint a second maze with level.index = 1, and the game has two levels.

  1. Add an Empty named MapLayer with Add Component ▸ Arcade ▸ Grid View: grid.var = map, grid.cell = 1, grid.plane = xz, and grid.tiles = the tile set’s address.

  2. Model the runner and give it Add Component ▸ Arcade ▸ Glide (or drag Glide Actor from the Simulacrum asset library): glide.cell = px,py, glide.grid = MapLayer, glide.time = 0.3, glide.face = 1.

  3. For each chaser, add an Empty with Glide (glide.cell = gx.0,gy.0 for chaser 0, and so on; glide.time = 0.4) and Add Component ▸ Arcade ▸ Look with look.var = gm.0.

  4. Parent three models to each chaser: itself, scared (deep blue) and eyes only. Give each child a look.value tag: 0,1 for itself, 2 for scared, 3 for the eyes.

  5. Bind left, right, up and down to the arrows and W A S D, and again to keys:Enter/KeyR/Space. Add a pad menu shown while playing, and an orthographic camera looking down (camera.at = 0,24,8, camera.target = 0,0,0.6, camera.orthoHeight = 11.4, camera.orthoMinWidth = 22).

Glide. The rules keep each actor’s cell as two numbers and step it one whole cell at a time; the model glides between cells. Either number may be an element of a list: gx.2 is element 2 of gx. A glide lasts as long as the last step took, up to glide.time, so a slow actor glides slowly and a fast one quickly. A jump of more than one cell, such as the tunnel from edge to edge or a reset, is a snap.

Look. On a parent, look.var names the variable whose value picks which child shows; each child’s look.value says when.

Grid Steer is a chaser’s choice at a cell. Of the open neighbours, it never takes the one straight back while another way is open, and takes the one nearest the target in a straight line. Ties go up, left, down, right. The target can be anywhere: inside a wall, ahead of the runner or off the map. Its wrap option joins the edges, which makes the tunnel.

The personalities are only where each one aims:

Chaser While chasing, it aims at
0 (crimson) The runner
1 (violet) Four cells ahead of the runner
2 (mint) The cell two ahead of the runner, mirrored through chaser 0: 2 × (runner + 2 × heading) − chaser 0
3 (amber) The runner while more than 8 cells away; its own corner when closer
  • Scatter (0 to 5 s, 25 to 30 s, 50 to 55 s): each aims at its own corner, off the map.
  • Scared: a random cell, at a slower pace.
  • Eyes: home, through the house door. Use two Grid Steer nodes, one that may pass the door and one that may not, and let an Expression pick.

Each chaser’s cell, heading and mode live in lists: gx, gy, gdx, gdy and gm. Array Set gives a copy of a list with one element replaced, so lists are values like grids. One function, chaserStep, is called four times from a For Loop.

  1. A 20 Hz tick. On Tick every 0.05 s. Each actor moves on its own beat from data/pace.json: ticks per cell for the runner (3), a chaser (4, then 3 from level 3), scared (6) and eyes (2), plus how long a fright and the READY pause last. Level N reads row N, up to the last row, so the game speeds up.

  2. The runner turns the way you asked as soon as it is open, and keeps going while the way ahead is open. A spark is worth 10 points; a core is worth 50 and scares the chasers.

  3. A core turns every chasing chaser round and scares it. Eaten while scared, chasers are worth 200, 400, 800 and 1600.

  4. The house lets the chasers out on ticks 0, 40, 140 and 240. Eyes that reach home come out again.

  5. Caught: a life is lost and everyone goes back to their places for READY. The last life ends the game and keeps the best score.

  1. Press Build Cartridge. It saves the file, bakes the level and packs the cartridge; a broken level stops it with the reason.

  2. Publish the tile set and the game (Publish and share) and open the game: the runner glides from cell to cell, and each chaser leaves the house on its own beat.

  3. Move a wall in Blender, build again, and the maze changes with it.

  • A level painted from objects and baked to a data table, checked on every build.
  • Glide moves a model smoothly between the cells the rules step; Look switches models by a variable.
  • Grid Steer and Array Set give four characters from one rule and one function.

Next: Blueprints and the Inspector shrinks this graph further and lets you watch it run.