Branch
Place a branch on the canvas, wire a true or false value into it, and give each answer its own white wire.
On this page
A branch is the yellow BRANCH node. It reads one true or false value and sends the white wire out of true or out of false, so you can see which nodes run in each case.
What it does
Section titled “What it does”The node has a red Condition pin on the left and two exec outputs on the right, true and false. When the game reaches it, it checks the value on Condition and runs the nodes wired to the matching output. After either side finishes, the method carries on with whatever comes after the branch.
A chain of branches, each one hanging off the false output of the one before, tests one question after another and stops at the first that is true. Each question is a separate red wire into a separate node, so you can see what every decision depends on without reading any expression.
The examples below come from FlowExamples, a class in the Platformer sample. Open UnlockGoal, ShowGoalVisual or AwardMedal to inspect each flow shape yourself.
When to use it
Section titled “When to use it”Reach for a branch whenever your game has to choose between two paths:
- Turn around when the enemy reaches the edge of its patrol, otherwise keep walking.
- Only collect a coin if it has not been collected already.
- Play the jump sound only if the player is on the ground.
- Open the door once the coin count reaches the target.
Add a second branch on false when you have a second question to ask only after the first one failed, such as “reached the left edge?” then “reached the right edge?”. When the choice is between several named states of one thing, a switch is tidier than a chain of branches.
What it looks like
Section titled “What it looks like”
if and else: FlowExamples.ShowGoalVisual. One bool pill drives the condition. Exactly one of the two calls runs on each pass.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. To compare each step with a finished diagram, open FlowExamples in the Platformer sample beside it; the steps name where each piece sits in UnlockGoal, ShowGoalVisual and AwardMedal.
Give a branch its question and its work
Place the branch
Right-click empty canvas to the right of the entry node. In the All actions menu, pick branch under flow control, or type
branchin Search and pick the branch row.
5 stepsFull size ↗Wire the entry node in
Drag from the entry node’s white Exec output to the branch node’s Exec input.
4 stepsFull size ↗Feed the condition
Give the branch its question. For a yes or no that is already stored, drag a bool variable from the Variables list in the left rail onto the canvas, choose get, and drag from the red pill to Condition.
9 stepsFull size ↗Compare two values instead
To compare two values instead, right-click the canvas and pick a comparison under operators, such as Less than, Greater than or Equals. Drag a variable from the Variables list in the left rail onto the canvas, choose get, and wire its pill into Left. Do the same for Right, or type a number into it. Then drag from Result to the branch’s Condition. To combine two answers, place And or Or between them and wire its Result to Condition.
22 stepsFull size ↗Give true its work
Place the work for the true side. Press on the branch’s white true output, drag onto empty canvas to its right, and let go; a menu opens there. Type the node you need, such as a method name or Log, or drag a variable in instead and choose set. If the true side does several things, chain more nodes from the new node’s Exec output.
6 stepsFull size ↗Add an else
To give the false side its own work, right-click the branch node and choose Edit branch arms. In the Branch arms popover, press Add else. Close the popover, then drag from false to the node that should run when the answer is no.
10 stepsFull size ↗Add an else if
To ask a second question only when the first fails, open Edit branch arms again and press Add else if. Wire the new branch’s Condition and its true output the same way as in Feed the condition, Compare two values instead and Give true its work.
6 stepsFull size ↗Wire an existing node into an arm
To put a node that is already on the canvas into an arm, drag from true or false onto that node’s Exec input.
Compile
Give each Log a message: type one directly into its pin, or wire one in. Give the second branch’s Condition a value the same way, typed directly in Edit branch arms or wired in. Press Compile in the top toolbar.
What it writes
Section titled “What it writes”If you also work in C#, this is what lands in the script. FlowExamples.UnlockGoal and FlowExamples.AwardMedal are written as:
For the Platformer sample’s EnemyPatrol FixedUpdate, the two branches write:
The value on Condition becomes the if condition. Nodes wired to true become the if body. Nodes wired to false become the else body, and a branch chained on false becomes else if. When every path on true leaves (a return, throw, break or continue), the nodes on false are written after the if instead, as a guard, rather than nested in an else. A node both paths reach is written once, after the whole shape. A branch you place starts with no else, which is why you press Add else in the Add an else step before wiring false.
When it goes wrong
Section titled “When it goes wrong”When it goes wrong
| Symptom | Check | Fix |
|---|---|---|
| Both sides of the work run. | Follow the white wire into the second branch. It should start at the first node's false output. | Drag the wire end onto false, or remove the second branch and use add else if in Edit branch arms. |
| The branch has no question. | Look at the condition pin. A hollow red dot means nothing is wired in. | Drag a red wire into condition from a bool pill or from the result of a comparison node. |
| Compile refuses a node you wired to false. | Open Edit branch arms and see whether the list ends with an else row. | Press add else, then wire the false output again and press Compile. |
- Loops: repeat a branch for every item in a list.
- Return and throw: put an EXIT node on one side of a branch to stop early.
- Guard clause: build the early-exit shape step by step.


