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

Loops

Read for, foreach, while, and do-while nodes, including indexes, completion, break, and continue.

A player can touch a surface through more than one contact point. The loop checks each contact until one has a strong upward-facing normal.

PlayerMotor.UpdateGrounded cannot assume contact zero represents the floor. It scans each contact, marks the player grounded when a normal points up past the threshold, then returns early.

Use for when an index and numeric bounds matter. Use foreach when the current element matters more than its position. Use while when the condition must pass before the first body run. Use do-while when the body must run once before the condition is checked.

Loop nodes expose exec outputs for loop body and completed. A for node is titled by its loop variable, with FOR on the right, and also exposes its index value. A foreach node exposes the current element and an array index. break exits to completion; continue skips the remaining body and starts the next iteration.

PlayerMotor UpdateGrounded scanning collision contacts
Figure 1. The loop checks each contact normal and returns as soon as it finds ground.
  1. Open PlayerMotor.UpdateGrounded and follow execution to the for node.

  2. Read the range pins. The node is titled i with FOR on the right. The source counts i from zero while it is below collision.contactCount, one step at a time, so the loop reads as a range: first index holds 0, step holds 1, and collision.contactCount is wired into last index.

  3. Follow loop body. The collision.GetContact(i) call runs first on each pass, then a branch compares that contact’s vertical normal with GroundNormalThreshold. The normal arrives as one Get pill, y with normal above it, on the call’s return wire.

  4. Follow the true branch. It sets _grounded to true, then returns before any remaining contacts are checked.

  5. Inspect the for loop type row in the right rail. It switches between From To and C-Style; the C-Style view moves the last index wire to the condition pin and back. The choice is stored as a for-loop type override in .rt.json, so the chosen presentation can return without changing the C# header by itself.

  6. For another loop form, add for, foreach, while, or do while from the flow-control actions. Connect body work and the completed continuation before Compile. A value wired into first index or last index is written as that bound, and typing a number over a wired bound replaces the wire.

The nodes the loop body wire reaches become the block, including a loop from the file whose body wire you rewired. The completed wire points to the next statement after it. A break writes an early exit from the enclosing loop; continue writes a jump to its next iteration.

When it goes wrong

SymptomCheckFix
Work that should run once repeats.See whether it is connected to loop body instead of completed.Move the post-loop statement to the completed output.
A for loop shows a C-style header instead of range pins.The parser uses range pins only for one variable counted by a fixed numeric step toward a number or a value, such as i < items.Length.Read the preserved header, or change only the visual type view if that presentation is clearer.
Break or continue affects the wrong loop.Trace its enclosing loop and nesting depth.Place the node inside the intended loop body before Compile.
  • Branch: understand the comparison inside the loop body.
  • Switch: route one value among several named paths.
  • Scan a list: practice the Platformer contact scan shape.
Full-size image