Skip to content
Bit Quirky Round Trip
Visual Scripting

Search documentation

All topics and APIs

Close returns focus to Search.

What are you looking for?

Try a common topic or a C# feature.

Browse the reference instead

Esc closes · Tab reaches results · Enter opens the focused link

v1.0.0
Menu

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.

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.

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.

  • 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

  1. 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 CheckUnlock in the name box and press Enter. The canvas shows a magenta entry node titled CheckUnlock with an Exec pin.

    Clip: the pointer presses Ctrl+O, the class picker opens and ScoreCounter is chosen; it clicks + on Methods, types CheckUnlock and presses Enter. While the + is pressed, it is highlighted with an arrow pointing at it. A magenta CheckUnlock entry node lands alone on the canvas with a white exec pin.
  2. 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 null on one Equals node and a _door pill with null on 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.

    Clip, part 1 of 3: the pointer right-clicks blank canvas and picks branch, wires the entry node's Exec into it, then gets a _rules pill and compares it with null on an Equals node. While the pointer rests on the entry node's Exec pin and on the _rules pill's output to drag from, each is highlighted with an arrow pointing at it. The menu choice is highlighted with an arrow pointing at it while the pointer rests on it: the branch row.
    Clip, part 2 of 3: a _door pill is compared with null on a second Equals node stacked below the first, both red Result wires join on an Or node, and the Or result is wired into the branch Condition. While the pointer rests on a pill or pin to drag from, it is highlighted with an arrow pointing at it.
    Clip, part 3 of 3: the view follows the true route. A _hud pill is dragged onto empty canvas and RefreshStatus is clicked; its isGoalUnlocked box is ticked and unticked again, the branch true output is wired into it and its Exec is wired into a return. While the pointer rests on a pill, box or pin to use, it is highlighted with an arrow pointing at it. The menu choice is highlighted with an arrow pointing at it while the pointer rests on it: the RefreshStatus row.
  3. 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.

    Clip: the pointer right-clicks blank canvas below the branch and types ShouldUnlock, then clicks its ƒ row. A teal ShouldUnlock node tagged CoinUnlockRule lands under the branch's false output with coinCount and threshold pins on the left and a bool output on the right, and the guard's false output is wired straight into its Exec. While the pointer rests on the guard's false output to drag from, it is highlighted with an arrow pointing at it. The menu choice is highlighted with an arrow pointing at it while the pointer rests on it: the ShouldUnlock row.
  4. 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.

    Clip: a green Coins pill beside ShouldUnlock is wired onto its coinCount pin; a _rules pill is gotten, then dragged to get coinUnlockThreshold, and its green pill, just left of ShouldUnlock, is wired onto threshold. No wire crosses another card. While the pointer rests on a pill to drag from, it is highlighted with an arrow pointing at it. Each menu choice is highlighted with an arrow pointing at it while the pointer rests on it: the get button on the Coins row, then the get button on the coinUnlockThreshold row.
  5. 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 newVar appears with the type int. Rename it shouldUnlock and 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.

    Clip: + is pressed on Local Variables, highlighted with an arrow, the new row is renamed shouldUnlock and retyped bool, then dragged onto the canvas and set shouldUnlock chosen. A shouldUnlock SET card lands just right of ShouldUnlock, with shouldUnlock on the left of its header and SET on the right, wired from ShouldUnlock's bool output into its Value input and from its exec output. The menu choice is highlighted with an arrow pointing at it while the pointer rests on it: the set shouldUnlock row.
The Variables and Local variables sections of the left rail.
Figure 1. The left rail. Local variables sits at the bottom with its own +; drag any row from Variables or Local variables onto the canvas to place a get pill or a SET node.

Show and act on the answer

  1. 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.

    Clip: a second _hud pill is gotten and dragged to call RefreshStatus, placed on the same row to the right of the SET node and wired from its exec output. An Or node is placed below that row; the SET node's Value output is wired onto its left, a _door pill's IsUnlocked just left of it onto its right, and Or's result onto RefreshStatus's isGoalUnlocked pin. While the pointer rests on a pill or pin to drag from, it is highlighted with an arrow pointing at it. Each menu choice is highlighted with an arrow pointing at it while the pointer rests on it: the RefreshStatus row, then the get button on the IsUnlocked row.
  2. 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.

    Clip: a branch is placed and wired from the second RefreshStatus's exec output; the SET node's Value output is wired onto its condition pin too. A _door pill is gotten and dragged to its door-opening member, wired from the branch's true output; false is left empty. While the pointer rests on a pill or pin to drag from, it is highlighted with an arrow pointing at it. Each menu choice is highlighted with an arrow pointing at it while the pointer rests on it: the branch row, then the row for the door-opening member.

Compile the method

  1. Compile

    Press Compile in the toolbar.

    The whole Graph view with CheckUnlock fully built and not yet compiled. The toolbar Compile button is amber, highlighted with an arrow pointing at it, and the Previewing your changes panel on the right counts the edits that are not in the C# file yet.
    The CheckUnlock canvas after pressing Compile, read left to right. The guard row with its null checks and Or sits on top. The ShouldUnlock rule call under the branch's false output feeds the shouldUnlock SET card. The second RefreshStatus has its Or below it, and the final branch calls the door. The graph is the one the steps built, reloaded from the saved script with every pill kept just before its pin.

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

SymptomCheckFix
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.
Full-size image