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 enter a complete API identifier.

Browse the reference instead

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

v0.89.0
Menu

Count and threshold

Follow a coin total through a rule call and a branch that opens the goal.

A coin count becomes useful when it crosses a line. ScoreCounter.OnCoinCountChanged asks one rule for that answer, updates the HUD, then acts only when the answer is true.

The score service knows how many coins have been collected. The goal door and HUD need a stable answer about whether that count is enough, including the case where the door is already open.

  • A running total triggers work at a configured value.
  • One pure calculation should feed both presentation and control flow.
  • The decision belongs in a named rule that can be read independently.
The OnCoinCountChanged graph with a guard, threshold call, HUD update, and final branch.
Figure 1. The shouldUnlock result feeds the HUD expression and the final branch.

The current Platformer source is:

C#
public void OnCoinCountChanged()
{
if (_rules == null || _door == null)
{
_hud?.RefreshStatus(isGoalUnlocked: false);
return;
}
var shouldUnlock = CoinUnlockRule.ShouldUnlock(Coins, _rules.coinUnlockThreshold);
_hud?.RefreshStatus(shouldUnlock || _door.IsUnlocked);
if (shouldUnlock)
{
_door.Unlock();
}
}
  1. Open ScoreCounter.OnCoinCountChanged in Graph View.

  2. Follow the missing-reference guard first. If _rules or _door is null, the HUD receives false and the method returns.

  3. On the continuing route, read the two inputs to CoinUnlockRule.ShouldUnlock: the Coins property and _rules.coinUnlockThreshold.

  4. Follow the returned Boolean into the local shouldUnlock. That one result fans out to two consumers.

  5. Read the HUD call. Its argument is shouldUnlock || _door.IsUnlocked, so an already-open door stays shown as open even if this refresh does not newly cross the threshold.

  6. Read the final branch. Only the true output calls _door.Unlock(); false reaches the end without a door call.

Adding one more step to the true route, such as a diagnostic after the door call, extends only that branch:

The calculation and HUD call stay where they are. The added call runs only when shouldUnlock is true.

When it goes wrong

SymptomCheckFix
The door call runs before the threshold is met.Follow the exec input to the door call.Keep it on the true output of the threshold-result branch.
The HUD says closed after the door is already open.Read whether the HUD input includes the door's existing state.Feed the existing door state into the HUD expression with the threshold result.
The graph repeats the threshold calculation.Count calls to the threshold rule.Store the result once and fan its data wire to each consumer.
Full-size image