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

Branch

Place a branch on the canvas, wire a true or false value into it, and give each answer its own white wire.

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.

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.

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.

FlowExamples.ShowGoalVisual on the canvas: a BRANCH node whose condition pin is wired from the _goalUnlocked pill, with true leading to ShowOpenGoal and false leading to ShowLockedGoal.
Figure 1. if and else: FlowExamples.ShowGoalVisual. One bool pill drives the condition. Exactly one of the two calls runs on each pass.

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

  1. 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 branch in Search and pick the branch row.

    Clip: the pointer right-clicks empty canvas to the right of the entry node; the all actions menu opens. It types branch in search and clicks the matching row. A yellow BRANCH node lands where it right-clicked, with exec and a red condition pin on the left and true and false on the right. While the pointer picks it, the branch row of the menu is highlighted, with an arrow pointing at it.
  2. Wire the entry node in

    Drag from the entry node’s white Exec output to the branch node’s Exec input.

    Clip: the pointer presses on the entry node's white exec output, drags a white wire onto the branch's exec input, and releases; a white wire now joins them. While the pointer drags, the entry node's exec output and the branch's exec input are highlighted, with an arrow pointing at them.
  3. 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.

    Clip: the whole Graph view window with the Variables list in the left rail. The pointer presses on _goalUnlocked's row in the Variables rail, drags it onto empty canvas, and releases; a get/set menu opens there. It clicks get, and a red _goalUnlocked pill lands at the drop point. The pointer then drags from the dot on the pill's right end to the branch's hollow Condition pin; a red wire joins them and the pin fills in. In turn the highlight marks the _goalUnlocked row of the rail, the get row of the menu, the pill's dot and the Condition pin, each with an arrow pointing at it.
  4. 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.

    Clip: the whole Graph view window with the Variables list in the left rail. On a separate branch, the pointer right-clicks empty canvas and types Greater Or Equal in search. It clicks the matching row; a red GREATER OR EQUAL node lands with Left and Right inputs and a Result pin, but no white pins. The pointer drags _coins from its row in the Variables rail onto empty canvas, chooses get, and drags the pill's dot onto Left; it does the same with _coinsToUnlock for Right. It then drags from Result to the branch's Condition pin, and a red wire joins them. In turn the highlight marks the Greater or equal row of the menu, the _coins row of the Variables rail, the get _coins row of the menu, the pill's dot, the Left pin, the _coinsToUnlock row, its get row, its pill's dot, the Right pin, the Result pin and the Condition pin, each with an arrow pointing at it.
  5. 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.

    Clip: the pointer presses on the branch's white true output, drags a white wire onto empty canvas to its right, and releases; a menu opens there. It types Log in search and clicks the matching row, and a dark teal Log call card lands at the drop point, already wired from true. The true output, then the Log row of the menu, are highlighted in turn, each with an arrow pointing at it.
  6. 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.

    Clip: the pointer right-clicks the branch node; a stand-in node menu opens and it clicks Edit Branch Arms. The branch arms popover opens beside the node, listing the one arm it has. The pointer clicks add else, a false row appears, and the popover closes. The pointer then drags from the branch's false pin to a Log node's exec input; a white wire joins them. The branch node, the Edit Branch Arms menu row, the add else row, the false pin and the Log's exec input are highlighted in turn, each with an arrow pointing at it.
  7. 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.

    Clip: the pointer right-clicks the branch node again; the stand-in node menu opens and it clicks Edit Branch Arms. The popover now lists the arm and the else you added. The pointer clicks add else if, and a second yellow BRANCH node is inserted before the else, already joined from the first branch's false output; the Log that was wired to the else now runs from the new branch's false output instead, and the popover closes. The branch node, the Edit Branch Arms menu row, then the add else if row are highlighted in turn, each with an arrow pointing at it.
  8. 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.

    A Log node that was already on the canvas now wired from the second branch's true output into its exec input, joining its arm. The second branch's true output and the Log's exec input are highlighted, with arrows pointing at them.
  9. 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.

    The whole Graph view window before Compile, showing this page's NewMethod draft: the entry node, the first BRANCH fed by _goalUnlocked with a Log on true, and a second BRANCH on false with a Log on each of its outputs, with the Previewing your changes notice at the top of the right rail. The gold Compile button in the top toolbar is highlighted, with an arrow pointing at it.
    The compiled NewMethod diagram with every card visible: the first BRANCH reads _goalUnlocked and sends true to Log. Its false wire reaches a second BRANCH, whose condition comes from GREATER OR EQUAL comparing _coins and _coinsToUnlock. The second branch's true and false outputs each reach their own Log with a typed message.

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

SymptomCheckFix
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.
Full-size image