Skip to main content

Logic and Math

Branching, looping, comparison and arithmetic. These are the nodes that give a script its shape.

Branching​

Branch​

The if node.

Execution inunnamed
Execution outTrue, False
Data inCondition — Bool (also settable as a constant)

CompareExec​

Compares two values and branches in one node. Prefer this over a separate Compare feeding a Branch.

Title{A} {Operator} {B}
Execution inunnamed
Execution outTrue, False
Data inA, B — Any
PropertyOperator — Equal, NotEqual, Less, LessEqual, Greater, GreaterEqual

SwitchInt64 / SwitchString​

Multi-way branch. Add entries to the Cases property and the node grows one execution output per case.

SwitchInt64SwitchString
TitleSwitchSwitch
Execution inunnamedunnamed
Execution outone per case, plus Defaultone per case, plus Default
Data inValue — Int64, requiredValue — HashedString, required
PropertyCases — up to 16 numbersCases — up to 16 strings

Comparison and boolean logic​

All of these are data nodes with no execution pins.

NodeTitleData inData out
Compare{A} {Operator} {B}A, B — Any"" — Bool
And{A} AND {B}A, B — Bool"" — Bool
Or{A} OR {B}A, B — Bool"" — Bool
NotNOT {A}A — Bool"" — Bool
IsValid—"" — Any, required"" — Bool
Select{Condition} ? {A} : {B}Condition — Bool; A, B — Any"" — Any

Compare takes the same Operator property as CompareExec.

IsValid is the one to remember: object and component references can go stale when something is deleted. Check before you use a reference you looked up earlier, particularly across a coroutine wait.

Select chooses between two values without splitting execution. Use it when both branches would otherwise do the same thing with a different number.

Loops​

Every loop node has two execution outputs: LoopBody runs once per iteration, Completed runs once when the loop finishes.

ForLoop​

TitleForLoop [{FirstIndex}..{LastIndex}]
Execution inunnamed
Execution outLoopBody, Completed
Data inFirstIndex, LastIndex — Int
Data outIndex — Int

The range includes both ends: 0 to 8 runs nine times.

WhileLoop​

Execution inunnamed
Execution outLoopBody, Completed
Data inCondition — Bool
warning

The condition is re-evaluated every iteration, all within a single frame. If it never becomes false the frame never ends. Put a Yield in the loop body if there is any chance of a long run.

ForEachLoop / ReverseForEachLoop​

Identical apart from direction.

Execution inunnamed
Execution outLoopBody, Completed
Data inArray — Array
Data outElement — Variant, Index — Int

Element is a Variant, so you will often need Variant_ConvertTo to use it.

Break​

Leaves the innermost loop immediately and continues from its Completed pin.

Execution inunnamed
Everything elsenone

Arithmetic​

Four data nodes, no execution pins, all working on numbers and vectors alike.

NodeTitleData inData out
Add{A} + {B}A, B — Any"" — Any
Subtract{A} - {B}A, B — Any"" — Any
Multiply{A} * {B}A, B — Any"" — Any
Divide{A} / {B}A, B — Any"" — Any

The output type is worked out from the inputs. Leave an input unconnected to type a constant into the property grid — that is how the jump pad multiplies its force by a fixed scale.

Expression​

A written formula, for when a chain of maths nodes would be unreadable.

Title{Expression}
Executionnone
Data inone pin per entry in Inputs
Data outone pin per entry in Outputs
PropertiesExpression — the formula; Inputs and Outputs — up to 16 each, named and typed

Each input and output is declared with a name and a type (Int, Float, Vector3 or Color), and the names become the variables in your formula.

See Also​