Count and threshold
Build a coin check on the canvas that asks one rule, shows the answer on the HUD, and opens the goal door.
On this page
A running total becomes useful when it crosses a line. On the canvas this shape is one rule node that answers yes or no, a SET node that keeps the answer, and red wires that carry that one answer to the HUD and to a final yellow BRANCH node. Only the branch’s true output opens the door. In the Platformer sample, the score counter checks the coin total this way every time it changes.
This page builds that shape from an empty canvas. It uses the sample’s ScoreCounter class so every name on the nodes is real. In your own project, build the same shape in any class that turns a count into a decision, once its folder is indexed.
In the sample
Section titled “In the sample”The score counter knows how many coins the player has collected. The goal door and the HUD both need one steady answer to “is that enough?”, and the HUD should keep showing the door as open once it has opened.
When this applies
Section titled “When this applies”- Collecting enough of something opens a door, opens the next level, or spawns a reward.
- The HUD should show the same answer the game acts on, so the two never disagree.
- The threshold is a tuning value a designer changes, kept in a rules asset or settings object.
Build the shape from an empty canvas
Create CheckUnlock
Open Tools > Round Trip > Graph view, press Cmd/Ctrl+O and choose ScoreCounter. Press the + on the Methods section of the left rail, type
CheckUnlockin the name box and press Enter. The canvas shows a magenta entry node titled CheckUnlock with an Exec pin.
7 stepsFull size ↗Guard the references
Start with a guard for missing references, built as on Guard clause. It is recorded in three parts. Place a branch from flow control and wire the entry node’s Exec into it. Compare a _rules pill with
nullon one Equals node and a _door pill withnullon another, join their red Result wires on an Or node from operators, and wire its Result into Condition. On the true route, get a _hud pill, drag from it onto empty canvas and click RefreshStatus; leave its isGoalUnlocked box unticked, then end the route at a return.Ask the rule
Ask the rule. Right-click blank canvas and type
ShouldUnlock. The rule lives on another class, and the menu’s search covers every method in the project once three letters are typed. Click its row, marked ƒ. A teal node titled ShouldUnlock appears with CoinUnlockRule above its title, coinCount and threshold pins on the left, and a red bool output on the right. Wire the guard’s false output into its Exec.
5 stepsFull size ↗Feed the rule
Fill the rule’s inputs. Right-click, type
Coins, press get, and drag the green pill onto coinCount. Get a _rules pill, drag from it onto empty canvas and press get on coinUnlockThreshold. Drag the new green pill onto threshold. Both wires are green because both values are whole numbers.
12 stepsFull size ↗Keep the answer
Keep the answer. In the left rail’s Local variables section, press + (its tooltip reads Add a local variable to this method). A row named
newVarappears with the type int. Rename itshouldUnlockand change its type to bool. Drag the row onto the canvas and choose set shouldUnlock. Wire the rule’s bool output into its Value input (red), and the rule node’s Exec output into the SET node’s Exec.
13 stepsFull size ↗

Show and act on the answer
Show the answer
Show the answer. Get a _hud pill, drag from it and click RefreshStatus. Wire the SET node’s Exec output into it. Place an Or node. Drag the SET node’s Value output onto Left. Get a _door pill, drag from it, press get on IsUnlocked, and wire that pill onto Right. Wire the Or node’s Result into isGoalUnlocked. An open door stays shown as open even when this check does not newly cross the line.
21 stepsFull size ↗Act on the answer
Act on the answer. Place a branch and wire the RefreshStatus node’s Exec output into it. Drag the SET node’s Value output onto Condition as well; one output can feed as many wires as you need. Drag from the _door pill, click
Unlock, and wire the branch’s true output into the new node. Leave false empty: when the count falls short, the method simply ends.
14 stepsFull size ↗
Compile the method
What it writes
Section titled “What it writes”If you also work in C#, this is the sample’s OnCoinCountChanged, the finished shape the steps build toward. Your CheckUnlock writes the same guard and rule call, followed by the HUD call and final if.
A node you add after the door’s Unlock node on the true route lands inside the final if. The rule call and the HUD call stay where they are.
When it goes wrong
Section titled “When it goes wrong”When it goes wrong
| Symptom | Check | Fix |
|---|---|---|
| The door opens before enough coins are collected. | Follow the white wire into the door call node. | Wire the door call from the true output of the final BRANCH node only. |
| The HUD shows the goal closed after the door has opened. | Look at what feeds the RefreshStatus node's isGoalUnlocked pin. | Feed it from an Or node that takes the shouldUnlock value and the door's IsUnlocked pill. |
- Branch: route a yes or no value.
- Operators and expressions: place Or, Equals and the other comparison nodes.
- Method calls: fill a call’s inputs from pills.




