Blueprints and the Inspector
For creatorsAdd-on 2.2.2+
In this tutorial you make graphs read more like formulas, and you watch a game run from inside Blender. Formulas read the graph’s variables by name, three nodes each do in one step what took three, and the node editor’s Inspector shows every value live, with breakpoints and live edits. The maze chaser rebuilt this way plays move for move the same, from 227 nodes instead of 382. This builds on tutorial 9, Maze chaser.
▶ Play the maze chaser, rebuilt with everything in this tutorial. The controls are the same as in tutorial 9.
1. Formulas read variables by name
Section titled “1. Formulas read variables by name”An Expression (from tutorial 6) still has its four pins a, b, c and d. Any other name in a formula is one of the graph’s variables, so you no longer need a Get Variable node and a wire for each one.
| You write | It reads |
|---|---|
score + 10 |
The variable score |
gm[a] |
Element a of the list variable gm |
map[px, py] |
The cell at (px, py) of the grid variable map, or −1 outside it |
playing |
A true/false variable, read as 1 or 0 |
Every name is checked against the graph’s declared variables, so a typo such as scor + 1 is an error before the game runs. A function’s formulas see its graph’s variables too.
2. One node where three stood
Section titled “2. One node where three stood”| Node | What it does | What it replaces |
|---|---|---|
| Set by Expression | variable = formula |
Get Variable, Expression and Set Variable |
| Set List Element | list[index] = value |
Array Set and Set Variable |
| Set Cell | grid[x, y] = value |
Grid Set Cell and Set Variable |
Each one stores a new list or grid, and saves it when the variable is persistent.
-
Open the maze chaser’s rules. Find a chain that reads a variable, does sums and stores the result, such as adding 10 to
scorefor a spark. -
Replace it with one Set by Expression:
variable=score, formulascore + 10. -
Replace each Array Set plus Set Variable pair with Set List Element, and each Grid Set Cell plus Set Variable pair with Set Cell (a spark eaten is
mapat the runner’s cell set to floor). -
Load the level’s and the pace table’s figures into variables once at the start, so formulas can name them.
The biggest saving is a chaser’s target, its whole personality. It took a 53-node function; now it is one formula per axis:
inHouse ? exitX : gm[a] == 3 ? homeX : gm[a] == 2 ? floor(c * 21) : (chasing ? (a == 0 ? px : a == 1 ? px + 4 * pdx : a == 2 ? 2 * (px + 2 * pdx) - gx[0] : (farFromRunner ? px : cornerX[a])) : cornerX[a])3. The Inspector
Section titled “3. The Inspector”Open a Node Editor on a Simulacrum Behaviour graph, open its sidebar, and choose the Simulacrum tab. Below the Graph panel, the Inspector panel has a status line, a debug bar and three parts:
| Part | What it shows |
|---|---|
| Node | The selected node’s type and settings (editable), and the variables it reads and writes, including every name inside a formula. A name the graph does not declare shows NOT DECLARED |
| Variables | Every variable of the graph: its type and scope, or its value now while the game runs, and how many nodes read and write it. Choose one in the Graph panel’s list to list those nodes here, each a click away, even inside a function. You edit variables in the Graph panel |
| Object | The selected object’s components and tags, and its own behaviour graph’s values |
4. Watch and debug the running game
Section titled “4. Watch and debug the running game”-
Press Play on the toolbar. The game opens in the viewer, linked to Blender, and the Inspector’s top line reads Live.
-
Watch the Variables: while the game runs, it sends every changed value up to four times a second.
scorecounts up,gmflips to 2 when a core is eaten, andmaploses its sparks. -
Select a node and press Set Breakpoint. A red dot marks it. The game pauses at the end of the tick in which that node ran, and the node gets a yellow outline.
-
Use the debug bar’s buttons to pause, continue, or step one tick (1/20 s). Its eye button turns on the trace, which outlines in green the nodes that just ran. Nothing is written into your file.
-
Press the pencil next to a variable (Set Live Value), type a value such as
12345,trueor[1,0,0,0], and the running game takes it at once.
Breakpoints are kept with the graph and never published.
5. Play runs data-driven games
Section titled “5. Play runs data-driven games”Play sends everything a game reads along with the scene: the data tables you keep as data/…json texts, the painted levels’ bake, and the sprite sheets you packed as sprites/… images. Files the game loads from other cartridges, such as a tile set or a spawnable, load from their published addresses.
What you learned
Section titled “What you learned”- Formulas name variables directly, and Set by Expression, Set List Element and Set Cell write in one node.
- The Inspector shows a node’s reads and writes and every variable’s live value, and finds every node that uses a variable.
- Breakpoints, stepping, trace and live edits debug the running game from Blender.
Next: Run-and-gun turns the board on its side and adds gravity.