Part 3 — Coins, your first logic graph and a HUD
Collectables, a score that goes up, and text on screen. This is where it becomes a game.
14 min readA level you can walk around is not yet a game. It becomes one the moment there is something to get and a number that goes up.
Make a coin
- Press ✨, generator
pickup, namecoin. - Options:
{ "palette": "canary", "radius": 10 }. - Add it and place one above a platform.
- Rename it
Coin.
Tags: the most important idea here
You are about to write one rule that covers every coin in the level, however many you make. That works because rules are written in terms of tags, not individual objects.
- With the coin selected, find Tags in the Inspector.
- Add the tag
coin. - Select the Player and add the tag
player.
Coins should not fall
Leave the coin's physics on but set the body to
static. It needs a body to be detected, but it should hang in
the air rather than dropping to the floor.
Now scatter them
Select the coin and press Ctrl/Cmd + D a dozen times, placing each copy somewhere worth reaching. Duplicates keep the tag and the physics, so every one is picked up by the rule you are about to write.
Your first logic graph
Switch to the Logic tab (or press 2). You
get an empty canvas and a palette of nodes on the left.
A graph starts at an event and follows the wires from its output. You are building this:
On Overlap (player, coin)
└─ Destroy (other)
└─ Add To Variable score + 10
- Drag On Overlap from the palette onto the canvas.
- Select it. In the Inspector set Tag A to
playerand Tag B tocoin. - Drag in a Destroy node and place it to the right.
- Set its Target to
other. - Drag from the exec pin on the right of On Overlap to the exec pin on the left of Destroy. A wire connects them.
- Drag in Add To Variable. Set Variable to
scoreand Amount to10. - Wire Destroy → Add To Variable.
Show the score
The score variable already exists — Blank 2D ships with it.
Now put it on screen.
- Back on the Scene tab, press + above the Hierarchy to add an entity.
- Set its Type to
bitmapText. - Set Layer to UI.
- Position it at X
40, Y36. - Set Origin X and Y to
0so it anchors from its top-left corner rather than its centre. - Add the behaviour
bindText. - Set its template to
SCORE {score}.
Anything in braces is replaced with that variable's live value. The text updates the instant the variable changes — you never refresh it from the graph.
Play it
Run into a coin. It should vanish and the score should jump by 10.
If the coins do nothing
- Open the console with F12. Anything prefixed
[gcs]is the engine telling you what it skipped. - Check both tags are spelled exactly as the node expects.
- Check both entities have physics enabled — overlap needs a body on each side.
- Check the wire actually connects. An unwired event runs nothing at all.
- Check Tag A is the player and Tag B is the coin, matching the Destroy target.
Next: something that can kill you.