Flow Control: Switch Nodes, Branch Node, ForLoop Node, etc...

Unreal Engine 5 Documentation - Flow Control 


Flow Control: Nodes that allow for controlling the flow of execution based on conditions.

 

Switch Nodes

A switch node reads in a data input, and based on the value of that input, sends the execution flow out of the matching (or optional default) execution output. There are several types of switches available: Int, String, Name, and Enum.

In general, switches have an execution input, and a data input for the type of data they evaluate. The outputs are all execution outputs. Enum switches automatically generate the output execution pins from the Enum's properties, while Int, String, and Name switches have customizable output execution pins. 



Standard Flow Control Nodes

The Branch node serves as a simple way to create decision-based flow from a single true/false condition. Once executed, the Branch node looks at the incoming value of the attached Boolean, and outputs an execution pulse down the appropriate output.

The DoN node will fire off an execution pulse N times. After the limit has been reached, it will cease all outgoing execution until a pulse is sent into its Reset input.

The DoOnce node - as the name suggests - will fire off an execution pulse just once. From that point forward, it will cease all outgoing execution until a pulse is sent into its Reset input. This node is equivalent to a DoN node where N = 1.

The FlipFlop node takes in an execution output and toggles between two execution outputs. The first time it is called, output A executes. The second time, B. Then A, then B, and so on. The node also has a boolean output allowing you to track when Output A has been called.

The ForLoop node works like a standard code loop, firing off an execution pulse for each index between a start and end. (WARNING: Loop iterations will take place between frames, so large loops may incur a performance hit.)

The ForLoopWithBreak node works in a very similar manner to the ForLoop node, except that it includes an input pin that allows the loop to be broken. (WARNING: Loop iterations will take place between frames, so large loops may incur a performance hit.)

A Gate node is used as a way to open and close a stream of execution. Simply put, the Enter input takes in execution pulses, and the current state of the gate (open or closed) determines whether those pulses pass out of the Exit output or not.

The MultiGate node takes in a single data pulse and routs it to any number of potential outputs. This can take place sequentially, at random, and may or may not loop.

The Sequence node allows for a single execution pulse to trigger a series of events in order. The node may have any number of outputs, all of which get called as soon as the Sequence node receives an input. They will always get called in order, but without any delay. To a typical user, the outputs will likely appear to have been triggered simultaneously.

A test condition and a body are all that make up a WhileLoop. Before executing the statement(s) in its body, the Blueprint evaluates WhileLoop's test condition to determine if it is true. After executing the statement(s) in its body, the Blueprint re-evaluates the test condition, and if the condition remains true, it keeps executing the statement(s) in the loop's body. Otherwise, if the test condition returns false, the Blueprint terminates the loop and exits the loop's body.