Flow

Flows control the execution of AFX graphs. For more information about flows, see Flows.

Flow And

Performs an AND logical comparison of Input 1 and Input 2, and continues the activating flow to one of two output ports depending on the result.

And node

Inputs:

Name
Type
Description

Enter

Flow

Flow to activate the node.

Input 1

Boolean [editable]

First value to compare.

Input 2

Boolean [editable]

Second value to compare.

Outputs:

Name
Type
Description

If True

Flow

The activating flow continues out of this port if Input 1 and Input 2 are both True.

If False

Flow

The activating flow continues out of this port if either Input 1 or Input 2 are False.

Example

The following example activates a game object when two different colliders are both at designated locations.

Example use of an And node to check for two conditions

Flow For

When activated, outputs a series of integer indexes. The full series of indexes are iterated through for each activation. The Body output port is activated once for each iteration.

For node

Inputs:

Name
Type
Description

Enter

Flow

Flow to activate the node.

Start

Int [editable]

Starting value for the index output. Must be zero or a positive integer.

End

Int [editable]

Value, that when exceeded, stops the iteration. Must be a positive integer.

Step

Int [editable]

Value to increment the index by in each iteration. Must be a positive integer.

Outputs:

Name
Type
Description

Exit

Flow

Continue the activating flow.

Body

Flow

Output flow that's activated for each iteration.

Index

Int

Index value that's output for each iteration.

Example:

The following example sets each item in a list of integers to the value 12 when the Start event is triggered.

Example use of a For node to set values in a list

Flow For Each

On activation, iterates through each item in the supplied list and send them sequentially to an output port. The Body output port is activated once for each item in the list.

For Each node

Inputs:

Name
Type
Description

Enter

Flow

Flow to activate the node.

Input

List

List to iterate through.

Outputs:

Name
Type
Description

Exit

Flow

Continue the activating flow.

Body

Flow

Output flow that's activated for each item in the input list.

Item

Varies

Appears after you connect a list to the Input port, and then has a type that matches the list. Sequentially outputs the items in the list.

Example

The following example iterates over each integer in int_list and checks if any of the values are greater than 5. If one is, the greater_than_5 Boolean reference is set to True.

Example use of For Each to compare each value in a list to a constant

Flow If

Diverts the input flow to one of two outputs, depending on whether the Input is true or false.

If node

Inputs:

Name
Type
Description

Enter

Flow

Flow to activate the node.

Input

Boolean [editable]

Value that determines whether the input flow is directed to the If True or If False outputs.

Outputs:

Name
Type
Description

If True

Flow

The input flow is directed to this output if Input is true.

If False

Flow

The input flow is directed to this output if Input is false.

Example

The following example plays one of two audio clips depending on whether the Y position of the moving_object reference is above or below zero.

Example use of an If node to set

Flow Null Check

Passes an activating flow to one of two outputs depending on whether the Input object is null.

Null Check node

Inputs:

Name
Type
Description

Enter

Flow

Flow to activate the node.

Input

Object

Object to be evaluated to determine if it's null.

Outputs:

Name
Type
Description

Is Null

Flow

Activated flow when the Input object is null.

Is Not Null

Flow

Activated flow when the Input object is not null.

Example

The following example rotates a game object if it's not null. You can assign the same game object to both reference properties in the Inspector panel. Unity will then cast the game object to the appropriate type.

Example to rotate a game object if a reference is provided

Flow Once

Passes an activating flow to the Once output one time only. Any subsequent activations of the node are passed to the After output. The Has Run Once parameter records whether the node has been activated. You can send an activating flow to the Reset input to reset Has Run Once to false.

Once node

Inputs:

Name
Type
Description

Enter

Flow

Flow to activate the node.

Reset

Flow

Flow to reset Has Run Once to false.

Parameters:

Name
Type
Description

Has Run Once

Boolean [editable]

Flag that's set to true after the node is activated.

Outputs:

Name
Type
Description

Once

Flow

Output flow that's activated if there is an input flow and Has Run Once is false.

After

Flow

Output flow that's activated if there is an input flow and Has Run Once is true.

Example

The following example adds 1 to score_ref the first time that passed_finish is set to true. Any subsequent changes to the value of passed_finish are ignored.

Example to add to a score one time, when a Boolean reference is true

Flow Or

Performs an OR logical comparison of Input 1 and Input 2, and continues the activating flow to one of two output ports depending on the result.

Or node

Inputs:

Name
Type
Description

Enter

Flow

Flow to activate the node.

Input 1

Boolean [editable]

First value to compare.

Input 2

Boolean [editable]

Second value to compare.

Outputs:

Name
Type
Description

If True

Flow

The activating flow continues out of this port if either Input 1 or Input 2 are True.

If False

Flow

The activating flow continues out of this port if both Input 1 and Input 2 are False.

Example:

The following example sets a game object to be active when either of two colliders reaches their designated points.

Example graph to enable a game object when either of two colliders reach their designated points

Flow Simple Timer

A timer that measures the time from its first activation to the value set by Duration. When the duration has elapsed, the activating flow is passed to the Completed output.

Simple Timer node

Inputs:

Name
Type
Description

Enter

Flow

Flow to activate the node.

Loop

Boolean [editable]

If true, the timer repeatedly measures the elapsed duration and passes a flow to the Completed output at the end of each cycle.

Duration

Float [editable]

The amount of time, in seconds, to measure between first activation and passing a flow to the Completed output.

Outputs:

Name
Type
Description

Started

Flow

The flow is passed to this output the first time the node is activated.

Tick

Flow

The flow is passed to this output for each activation of the node when the timer is running.

Completed

Flow

The flow is passed to this output when the amount of time defined by Duration has passed.

Elapsed

Float

The amount of time, in seconds, that has passed since the timer started. If Loop is set to true, Elapsed is the amount of time that has passed in the cycle.

Remaining

Float

The amount of time remaining, in seconds, until the Duration has passed. If Loop is set to true, Remaining is the amount of time remaining in the cycle.

Example

The following example starts a ten second timer, updates count_down_ref with the time remaining, and activates the fireworks game object when the timer reaches zero.

Example graph to update a countdown and activate a game object at zero

Flow Timer

A timer that measures the time from its first activation to the value set by Duration. When the duration has elapsed, the activating flow is passed to the Completed output.

This is a more advanced version of the Simple Timer node and includes additional options.

Timer node

Inputs:

Name
Type
Description

Enter

Flow

Flow to activate the node.

Restart

Flow

If activated by a flow, the count of time elapsed is reset to zero.

Pause

Flow

If activate by a flow, the timer countdown is paused.

Resume

Flow

If activated by a flow, the timer countdown will continue if the timer was in a paused state.

Toggle

Flow

When activated by a flow, pauses the timer if it was running or resumes the timer if it was paused.

Loop

Boolean [editable]

If true, the timer repeatedly measures the elapsed duration and passes a flow to the Completed output at the end of each cycle.

Duration

Float [editable]

The amount of time, in seconds, to measure between first activation and passing a flow to the Completed output.

Unscaled time

Boolean [editable]

Provides a time that's unaffected by time scaling. For more information about time scaling, refer to the Unity documentation for Time.timeScale.

Outputs:

Name
Type
Description

Started

Flow

The flow is passed to this output the first time the node is activated.

Tick

Flow

The flow is passed to this output for each activation of the node when the timer is running.

Completed

Flow

The flow is passed to this output when the amount of time defined by Duration has passed.

Elapsed

Float

The amount of time, in seconds, that has passed since the timer started. If Loop is set to true, Elapsed is the amount of time that has passed in the cycle.

Remaining

Float

The amount of time remaining, in seconds, until the Duration has passed. If Loop is set to true, Remaining is the amount of time remaining in the cycle.

Example

The following example starts a 60 second timer, updates count_down_ref with the time remaining, and activates the fireworks game object when the timer reaches zero. It also pauses or resumes the timer based on the value of the the timer_toggle reference.

Example to update a countdown and activate a game object, with options to pause and resume the countdown

Flow Toggle

Provides advanced branching and flow control. You can use the Toggle node to turn a flow on and off, invert a flow, and identify when a flow changes state.

Toggle node

Inputs:

Name
Type
Description

Enter

Flow

Flow to activate the node.

Turn On

Flow

If activated by a flow, sets the node to an on state.

Turn Off

Flow

If activated by a flow, sets the node to an off state.

Toggle

Flow

If activated by a flow, toggles the node between an on and off state.

Outputs:

Name
Type
Description

On

Flow

If the node is set to an on state, the activating flow continues through this output.

Off

Flow

If the node is set to an off state, the activating flow continues through this output.

Turned On

Flow

The activating flow is passed to this output when the node transitions from an off state to an on state.

Turned Off

Flow

The activating flow is passed to this output when the node transitions from an on state to an off state.

Is On

Boolean

Outputs true is the node is in an on state and false if the node is in an off state.

Example

The following example toggles the rotation of a game object on and off each time that a collision is detected.

Example graph to toggle a rotation on and off

Last updated