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

Scan a list

Build a for loop on the canvas that checks each collision contact and stops at the first one that faces up.

A scan visits the items of a collection one at a time and stops at the first one that matches. On the canvas it is a yellow FOR node whose Loop body output runs a check on each item, with a magenta EXIT node on the route that finds a match. In the Platformer sample, a collision can touch the player at several points, and the motor scans those contact points until one faces up steeply enough to count as ground.

This page builds that shape from an empty canvas. It uses the sample’s PlayerMotor class so every name on the nodes is real. In your own project, build the same shape in any class that looks for a first match, once its folder is indexed.

This uses the simple From to view: count from 0 up to, but not including, contactCount. Keep Inclusive off because a collection’s last position is one less than its count. You do not need the advanced C-Style controls for this scan; the loop guide explains why both views exist.

When the player lands on a corner, the first contact point can face sideways while another faces up. Reading only the first contact misses the floor. The motor checks each contact, and stops as soon as one proves the player is standing on something.

  • A collision, overlap or raycast returns several hits and you need the first one that qualifies.
  • You are looking for one item in a list, such as the first enemy in range or the first free spawn point.
  • Once you have found it, checking the rest would only waste the frame.

Scan the collision contacts

  1. Create FindGround

    Open Tools > Round Trip > Graph view, press Cmd/Ctrl+O and choose PlayerMotor. Press the + on the Methods section of the left rail, type FindGround in the name box and press Enter. In the right rail’s Inputs card, press +, choose Collision2D as the type and type collision as the name. The magenta entry node titled FindGround now has an Exec pin and a purple collision pin.

    Choose PlayerMotor and add a FindGround method with a Collision2D collision input. The plus on Methods and the plus on the right rail's Inputs card are each highlighted with an arrow while the pointer presses them.
    The whole Graph view with PlayerMotor open. The plus beside Methods on the left rail is highlighted, with an arrow pointing at it.
    The whole Graph view with the new FindGround entry node on the canvas. The plus on the right rail's Inputs card is highlighted, with an arrow pointing at it.
  2. Place the loop

    Right-click blank canvas and pick for under flow control. A yellow node titled i with FOR in its header appears. On its left are Exec, first index holding 0, last index holding 10 and step holding 1; on its right are Loop body, Completed and a green index output. Wire the entry node’s Exec into the loop’s Exec.

    Place a FOR node and wire the FindGround entry into it. While the pointer rests on the entry node's Exec pin 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 for row.
  3. Count the contacts

    Count the contacts. Drag from the entry node’s collision pin and let go on empty canvas. A menu headed by the collision lists its variables and methods; press get on contactCount. Drag the green contactCount pill onto last index.

    Get contactCount from collision and connect it to the loop's last index. While the pointer rests on the collision pin and on the contactCount pill 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 get button on the contactCount row.
  4. Read a contact

    Read one contact per pass. Drag from the collision pin again and click GetContact. A teal node titled GetContact appears with its Target already wired, an index pin, and a contact output on the right. Wire Loop body into its Exec, and the loop’s green index output into its index pin.

    GetContact receives the loop body and the loop index. While the pointer rests on a pin 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 GetContact row.
  5. Read its normal

    Read how much the contact faces up. Drag from the GetContact node’s contact output and press get on normal. Drag from the new pill and press get on y. A green y pill appears, the number you compare.

    Read normal from the contact, then read its y component. While the pointer rests on the contact output pin and on the normal pill to drag from, each 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 normal row, then the get button on the y row.
  6. Compare with the threshold

    Compare. Right-click and type Greater Than, then pick the Greater than row. Wire the y pill into Left. Right-click, find GroundNormalThreshold (type its name if needed), press get, and wire that pill into Right.

    Compare the contact normal's y component with GroundNormalThreshold. While the pointer rests on the y pill and on the GroundNormalThreshold pill to drag from, each 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 Greater than row, then the get button on the GroundNormalThreshold row.
  7. Branch on the result

    Decide. Place a branch, wire the GetContact node’s Exec output into it, and wire the Greater than node’s red Result into Condition.

    Wire GetContact and the comparison result into a branch. While the pointer rests on a pin 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 branch row.
  8. Stop on a match

    Stop at the first match. Right-click, type _grounded, and press set. Tick its Value box. Wire the branch’s true output into it. Place a return and wire the SET node’s Exec output into the magenta EXIT node. Leave the branch’s false output empty: that pass ends there and the loop moves on to the next contact.

    Wire the branch's true path through a true _grounded SET and a return. While the pointer rests on a pin 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 return row.
  9. Compile and reload

    Press Compile in the toolbar.

    The whole Graph view with the finished FindGround graph. The toolbar Compile button is amber and highlighted with an arrow pointing at it, because the canvas holds changes that are not in the C# file yet.
    The reloaded FindGround graph reads a contact, compares its normal, sets grounded and exits on a match.

If you also work in C#, this is the sample’s UpdateGrounded, the finished shape the steps build toward. Your FindGround writes the same loop.

The return ends the method immediately. If no contact passes the threshold, the loop completes without setting _grounded.

Sometimes you want every item that matches: how many coins the player has picked up, or which enemies are still standing. A Where node keeps the items that pass a test, and a Count node counts them, with no loop to wire. These steps build that on the sample’s ScoreCounter class, counting the collected coins in a list and writing the number to the Console.

Filter collected coins

  1. Create ReportCollected

    Press Cmd/Ctrl+O and choose ScoreCounter. Press the + on the Methods section of the left rail. The new method’s row opens as a name box: type ReportCollected and press Enter. In the right rail’s Inputs card, press +. The new row reads int and newParam. Press int, type List and pick List<T>, then type Coin and pick Coin, so the row reads List<Coin>. Type coins over newParam.

    Choose ScoreCounter and add a ReportCollected method with a List of Coin coins input. The plus on Methods and the plus on the right rail's Inputs card are each highlighted with an arrow while the pointer presses them.
    The whole Graph view with ScoreCounter open. The plus beside Methods on the left rail is highlighted, with an arrow pointing at it.
    The whole Graph view with the new ReportCollected entry node on the canvas. The plus on the right rail's Inputs card is highlighted, with an arrow pointing at it.
  2. Add the log

    Right-click blank canvas to the right of the entry node and pick Log in the LOGGING group. A dark teal Log node appears. Drag the entry node’s white Exec pin into its Exec. Leave its message pin empty for now: the Count node feeds it in step 6.

    Right-click blank canvas, pick Log, and wire the entry node's Exec into it. While the pointer rests on the entry node's Exec pin 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 Log row.
  3. Place Where

    Right-click blank canvas below the entry node and scroll to the LINQ group, or type Where in search. Every row in the group is marked Q. Pick Where. A green node titled Where appears with LINQ on the right of its header, source and Condition on its left, and Result and item on its right.

    Open the canvas action menu and place a Where node. While the pointer rests on the Where row of the menu, it is highlighted with an arrow pointing at it.
  4. Feed the collection

    Drag the entry node’s purple coins pin into the Where node’s source pin. item now stands for one coin, and Result for the coins that pass.

    Wire coins into the Where node's source. While the pointer rests on the coins pin to drag from, it is highlighted with an arrow pointing at it.
  5. Test each coin

    Drag from the item pin and let go on empty canvas. A menu headed item lists the coin’s variables; type IsCol and press get on IsCollected. A red IsCollected pill appears, already wired from item. Drag its output into the Where node’s red Condition pin.

    Read IsCollected from each item and wire it to Where's condition. While the pointer rests on the item pin and on the IsCollected pill 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 get button on the IsCollected row.
  6. Count and print

    Right-click blank canvas to the right of the Where node and pick Count in the LINQ group. The new green node reads LINQ · RUNS NOW on the right of its header, because it produces the number at once. Drag the Where node’s Result into the Count node’s source, then drag the Count node’s green Result into the Log node’s message pin. The message pin turns green, because it now receives a number.

    Wire Where through Count into the Log message. While the pointer rests on a Result pin 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 Count row.
  7. Compile and reload

    Press Compile in the toolbar.

    The whole Graph view with the finished ReportCollected graph. The toolbar Compile button is amber and highlighted with an arrow pointing at it, because the canvas holds changes that are not in the C# file yet.
    The reloaded ReportCollected graph connects Count directly to the Log message.

Dragging a data pin onto empty canvas opens its member menu, not a menu of LINQ operators, so place each LINQ node from the right-click menu and drag the wire into its source pin. The other operators in the group work the same way: Select has a value pin, Order By a key pin, and Take a count box you type a number into.

If you also work in C#, this is what Compile writes for the chain. ScoreCounter’s script had neither using System.Linq; nor using System.Collections.Generic;, so Compile added both after its existing using lines.

When it goes wrong

SymptomCheckFix
Only the first contact is ever checked.Look at what feeds the GetContact node's index pin.Wire the FOR node's green index output into it, and keep GetContact on the loop body route.
Touching a wall marks the player grounded.Look at the comparison node between the y pill and GroundNormalThreshold.Use Greater than with y on left and the threshold on right, feeding the branch's condition.
Contacts are still checked after ground is found.Follow the white wire out of the _grounded SET node.Wire it straight into a magenta EXIT node placed from return.
Full-size image