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. Make the tile set
Section titled “1. Make the tile set”-
Save a new file as
maze-tiles.blendand model six tiles for a 1-metre cell, each tagged withtile.valueandtile.nameas in tutorial 5: floor 1, wall 2, spark 3, core 4, the house door 5, the house floor 6. -
Press Build Cartridge.
2. Paint the level
Section titled “2. Paint the level”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.
-
In a new file,
maze-chaser.blend, add an Empty namedLevel. In Object Properties ▸ Custom Properties, give itlevel=1andlevel.size=21,21. Addlevel.marks=start,exit,hometo make those marks required. -
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 propertycell.valuewith its tile’s value. Cells you leave empty are 0. -
Add marker Empties under
Level, each with the custom propertylevel.mark:start(where the runner starts),exit(where the house door opens) andhome(where eyes go back to). Marks named with a number at the end,sentry0tosentry3, also become lists in that order: the chasers’ starting places. -
Give
Leveland everything under it the custom propertysim.source=1. The.blendkeeps them; the published world never receives them. -
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.
3. Draw the maze and its actors
Section titled “3. Draw the maze and its actors”-
Add an Empty named
MapLayerwith Add Component ▸ Arcade ▸ Grid View:grid.var=map,grid.cell=1,grid.plane=xz, andgrid.tiles= the tile set’s address. -
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. -
For each chaser, add an Empty with Glide (
glide.cell=gx.0,gy.0for chaser 0, and so on;glide.time=0.4) and Add Component ▸ Arcade ▸ Look withlook.var=gm.0. -
Parent three models to each chaser: itself, scared (deep blue) and eyes only. Give each child a
look.valuetag:0,1for itself,2for scared,3for the eyes. -
Bind
left,right,upanddownto the arrows and W A S D, andagaintokeys:Enter/KeyR/Space. Add a pad menu shown whileplaying, 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.
4. Four personalities, one rule
Section titled “4. Four personalities, one rule”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.
5. Keep the four chasers in lists
Section titled “5. Keep the four chasers in lists”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.
6. The rest of the rules
Section titled “6. The rest of the rules”-
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. -
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.
-
A core turns every chasing chaser round and scares it. Eaten while scared, chasers are worth 200, 400, 800 and 1600.
-
The house lets the chasers out on ticks 0, 40, 140 and 240. Eyes that reach home come out again.
-
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.
7. Build and play
Section titled “7. Build and play”-
Press Build Cartridge. It saves the file, bakes the level and packs the cartridge; a broken level stops it with the reason.
-
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.
-
Move a wall in Blender, build again, and the maze changes with it.
What you learned
Section titled “What you learned”- 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.