Description: The Do Once node is a special kind of flow control node that allows the connected actions to execute only one time. After it’s been triggered once, it will not allow the flow to continue again unless it is reset.
Use Case: You might use Do Once to trigger an event or action that should only happen once during the game, such as opening a door or playing a sound. For example, you can use it in a level to play a sound effect only the first time the player enters a specific area.
Resetting: You can reset the Do Once node manually by calling its Reset input, which allows the node to trigger its output again.
For Loop
Description: The For Loop node executes a series of actions a specific number of times. You define the starting index (First Index) and the ending index (Last Index), and the loop will execute for every integer value between these two (inclusive).
Flow:
The loop starts at the First Index.
Executes the connected actions.
Increments the index and repeats until it reaches the Last Index.
Use Case: You can use a For Loop to spawn multiple objects, iterate through an array of values, or apply changes to a series of items. For example, spawning five enemies at the start of a level using a loop with indices from 0 to 4.
For Each Loop
Description: The For Each Loop node is designed to iterate over each element in an array, performing the connected actions on each item. It’s particularly useful when you need to work with every item in an array, such as modifying properties, applying a function, or checking conditions.
Flow:
The loop iterates over each element in the array.
Executes the connected actions for the current element.
Moves to the next element and repeats until all elements have been processed.
Use Case: Suppose you have an array of actors and you want to change the material of each actor in the array. You can use a For Each Loop to iterate over the array and apply the material change to each actor.
While Loop
Description: The While Loop node continues to execute its connected actions as long as a specified condition remains true. The loop will keep running indefinitely until the condition becomes false or the loop is manually stopped.
Flow:
Checks the condition.
If the condition is true, it executes the connected actions.
After executing the actions, it checks the condition again.
Repeats this process until the condition becomes false.
Use Case: A While Loop might be used to continuously check if a player is within a certain area and apply an effect (like reducing health) as long as they stay within that area. Another example might be to continue to check if a resource (like health or ammo) is below a certain threshold and refill it until it meets a required level.