Flow
Last updated
Last updated
Flows control the execution of AFX graphs. For more information about flows, see Flows.
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.
Inputs:
Enter
Flow
Flow to activate the node.
Input 1
Boolean [editable]
First value to compare.
Input 2
Boolean [editable]
Second value to compare.
Outputs:
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.
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.
The value of Index
is guaranteed to be between Start
and End
only for nodes activated from the Body
port. Nodes activated from the Exit
port may have one additional increment of the Step
value.
Inputs:
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:
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.
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.
Inputs:
Enter
Flow
Flow to activate the node.
Input
List
List to iterate through.
Outputs:
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.
Diverts the input flow to one of two outputs, depending on whether the Input
is true or false.
Inputs:
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:
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.
Passes an activating flow to one of two outputs depending on whether the Input object is null.
Inputs:
Enter
Flow
Flow to activate the node.
Input
Object
Object to be evaluated to determine if it's null.
Outputs:
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.
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.
Inputs:
Enter
Flow
Flow to activate the node.
Reset
Flow
Flow to reset Has Run Once
to false.
Parameters:
Has Run Once
Boolean [editable]
Flag that's set to true after the node is activated.
Outputs:
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.
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.
Inputs:
Enter
Flow
Flow to activate the node.
Input 1
Boolean [editable]
First value to compare.
Input 2
Boolean [editable]
Second value to compare.
Outputs:
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.
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.
The timer node requires repeated activation, such as from an Update event, to measure the time passed.
Inputs:
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:
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.
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.
Inputs:
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]
Outputs:
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.
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.
Inputs:
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:
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.
Provides a time that's unaffected by time scaling. For more information about time scaling, refer to the Unity documentation for .