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

Call a neighbor

Trace CollectCoin as a guarded sequence of calls into the coin, score, HUD, and audio collaborators.

Collecting a coin is a handoff. PlayerController.CollectCoin validates the moment, then asks four collaborators to do the work they own.

The player detects the trigger, but the coin owns collection state, the score counter owns totals, the HUD owns presentation, and the audio service owns sound. Putting all of that work in the player would blur those responsibilities.

  • One interaction coordinates several scene components.
  • Each receiver already has a method that names its responsibility.
  • The order of calls matters and should be visible on the exec wire.
The CollectCoin graph with its guards and four collaborator calls.
Figure 1. The call sequence moves from the local coin to scene services and optional audio.

The current Platformer source is:

C#
public void CollectCoin(Coin coin)
{
if (coin == null || coin.IsCollected)
{
return;
}
if (_scoreCounter == null || _hud == null)
{
_logger?.LogWarning(
"player controller cannot collect a coin; its score counter or HUD reference is " +
"unassigned. wire both on the player to enable coin collection.");
return;
}
coin.Collect(); // local (trigger-provided)
_scoreCounter.AddCoins(CoinsPerPickup); // scene
_hud.RefreshCoins(_scoreCounter.Coins, _scoreCounter.Score); // scene
_audio?.PlayCoin(); // composed (optional)
}
  1. Open PlayerController.CollectCoin in Graph View.

  2. Follow the first guard. A missing or already-collected coin returns before any neighbor call.

  3. Follow the second guard. Missing required score or HUD references produce a warning, then return. The audio service is optional, so it is not part of this guard.

  4. On the success route, read the first receiver pin: the coin parameter calls Collect on the trigger-provided instance.

  5. Continue to _scoreCounter.AddCoins. Its argument comes from the CoinsPerPickup constant pill.

  6. Continue to _hud.RefreshCoins. Its two arguments read the score counter’s updated Coins and Score properties.

  7. Finish at _audio?.PlayCoin(). The conditional call runs only when the composed audio service exists.

Adding one more optional step after audio, such as a collection diagnostic, extends the end of the sequence:

The new call runs only after required collection, scoring, and HUD work succeeds. It does not need a new guard because the logger call is conditional.

When it goes wrong

SymptomCheckFix
The HUD shows the previous coin total.Read whether RefreshCoins runs before AddCoins.Keep the score update earlier on the exec wire.
A missing audio service stops collection.Inspect the receiver form on PlayCoin.Keep the audio call conditional so required work does not depend on it.
The same coin scores twice.Follow the coin.IsCollected guard and confirm coin.Collect runs first.Return for an already-collected coin before calling the score counter.
  • Method calls: choose a receiver and fill its argument pins.
  • Get and set: read updated properties for the next call.
  • Branch: protect required collaborators with early exits.
Full-size image