Skip to content

Switch Node

The Switch Node is very similar to the condition node in that it allows for branching of the editor flow based on the value of a variable. The advantage of using the switch node is that you can have more than two sockets for the same variable. If a value is not defined it will route the flow through the default-socket.

Switch Node
Variable The name of the variable.
Cases The value you want to compare to the variable

switch

You can use Built-in Functions directly in the variable field, to quickly create a flow that branches randomly. The following example can be pasted directly into the variable-field of a switch node and will randomly generate a number between 0 and 3.

Math.floor(Math.random() * 3)

The Math.floor() function rounds the argument down to the nearest integer
The Math.random() function generates a random number between 0 and 1

You can also add operators to the value fields for greater control over which socket is chosen. Note that if you're using the "AND" (&&) operator, You need to add the name of the variable with curly brackets after the operator as shown in the picture below.

ampersand

Operators
IS === if the variable IS the same as the value
IS NOT != if the variable IS NOT the same as the value
GREATER THAN > if the variable is HIGHER than the value
LESS THAN < if the variable is LOWER than the value
GREATER THAN OR EQUAL TO >= if the variable is HIGHER OR the SAME as the value
LESS THAN OR EQUAL TO <= if the variable is LOWER OR the SAME as the value
AND && add multiple operators