Switch
Place a switch on the canvas, wire the value it decides on, add a case for each value, and give every case its own white wire.
On this page
A switch is one yellow node that looks at a single value and sends the white wire down a different output for each value it can hold. You build it by placing the node, wiring the value in, and adding one case per value.
What it does
Section titled “What it does”The switch node takes one value on its Selection pin. On its right edge it grows one exec output per case, each labeled with the value it matches, plus default when you add one and Completed, which always carries on to whatever runs after the switch. When the game runs, exactly one case output fires: the one whose label matches the value on Selection, or default when none does. If nothing matches and there is no default, the switch goes straight to Completed.
Each case owns the nodes on its own white wire. Reading the node from top to bottom tells you every value it handles and what each one does, side by side.
When to use it
Section titled “When to use it”Reach for a switch when one thing in your game is in one of several named states and each state needs different behavior:
- An enemy that patrols, chases, or is stunned, where each state turns movement and damage on or off.
- A pickup that does something different per item type: a coin adds score, a heart restores health, a key opens a door.
- A menu that reacts to which tab is selected, or a weapon that fires differently per firing mode.
If the decision is a plain yes or no, use a branch. If each path depends on a different, unrelated question, chain branches instead.
A second form, switch expression, picks a value instead of picking a path: for example, the speed to use for each enemy state. It is covered at the end of the steps.
How to use it
Section titled “How to use it”Start in a method whose canvas holds only its magenta entry node, the node titled with the method’s name that has an Exec pin and a self pin. A new method from the + beside Methods in the left rail starts that way.
Build a switch with case paths
Place a switch
Right-click empty canvas to the right of the entry node. Pick switch under flow control, or type
switchand pick the switch row.
6 stepsFull size ↗Wire the entry
Drag from the entry node’s white Exec output and drop on the switch node’s Exec input.
4 stepsFull size ↗Feed the selection
Give the switch its value. Drag the variable it should decide on from the Variables list in the left rail onto empty canvas left of the switch, and choose get. Drag from the pill’s output pin to the switch’s Selection pin.
9 stepsFull size ↗Select the switch and add a case
Click the switch node to select it. In the right rail, press Add case, or press Add pin on the node itself.
Choose a match
Open the matches dropdown and pick the value this case handles.
Add the remaining cases
Repeat Select the switch and add a case and Choose a match for every value that needs its own behavior. Use ↑ (Move earlier) and ↓ (Move later) to change the order. To catch every value you did not list, add one more case and press its ◇ (Make this the default).
5 stepsFull size ↗Place the first case’s work
Place the work for the first case. Right-click empty canvas to the right of the switch, type the name of the method that case should call, and pick it. Drag from the first case output on the switch to the call node’s Exec input.
8 stepsFull size ↗Fill and chain the call
Fill the call node’s own pins: tick a checkbox, type a number into a literal field, or wire a pill into a colored pin. Chain more nodes after it by dragging from its Exec output to the next node’s Exec input, or drag onto empty canvas and pick the next node from the menu.
8 stepsFull size ↗Wire the remaining cases
Repeat Place the first case’s work and Fill and chain the call for each remaining case output.
17 stepsFull size ↗Wire completed
If something should run after the switch whichever case ran, place that node and drag a white wire to it from Completed.
9 stepsFull size ↗Compile
Press Compile in the top toolbar.
To pick a value instead of a path, place switch expression from flow control in the Place a switch step. It lands as a table with PATTERN and RESULT columns, a dashed Add case row, and FIRST MATCH WINS along the bottom. Wire the value it decides on into its selection pin, press Add case for each row, click a row’s pattern cell to choose its value from the Match on list (the last entry, Anything else, catches everything left), and type the result into the row’s RESULT cell. Then wire the node’s result into the pin that uses it, such as a SET node’s Value.
Right-click a switch and choose Edit switch cases to do the same case work in a popover beside the node: Switch cases lists every case with Add case, Remove, Move up, Move down, Make default and Clear default. It works on a switch you placed and on one that came from the script.
What it writes
Section titled “What it writes”If you also work in C#, this is what lands in the script. The Platformer sample’s ApplyState is one switch from top to bottom, and it writes:
Each case output becomes a case label, the nodes on its wire become that case’s statements, and a new case ends with break. A case marked default becomes default:. A When guard on a case adds a when condition after its label. A switch expression writes the x switch { ... } form, with one arm per table row, into whichever pin its result is wired to. A goto case or goto default node appears when a script jumps from one case into another.
When it goes wrong
Section titled “When it goes wrong”When it goes wrong
| Symptom | Check | Fix |
|---|---|---|
| The matches dropdown is a plain text field with no list. | Select the switch and read its type row. A note under the cases asks you to wire a value into selection. | Wire a pill into selection so the rail knows the type and offers its values. |
| Compile refuses the switch. | Select the switch and look for a case card in the right rail whose matches row still reads (not chosen). | Pick a value for that case, or remove it with ×. |
| A value runs none of the cases. | Look for a default output on the node. Without one, an unmatched value leaves through completed. | Add a case and press its ◇ button to make it the default, then wire its output. |
| The wrong case runs. | Read the case order in the right rail. The first case whose value matches is the one that runs. | Use the ↑ and ↓ buttons to move the case, or check its when field. |
- Return and throw: end a case by leaving the method.
- Switch on a state: build the enemy state switch step by step.
- Enums and data classes: define the values a switch decides on.




