sexta-feira, 25 de março de 2016

BP Compendium: For Each Loop

For Each Loop


Takes as input parameter an Array and performs the set of actions that are associated with the output pin "Loop Body" for each element of the Array that can be obtained from the output pin "Array Element". After that the execution flow is directed to the output pin "Completed".

Input

  • Array:  Array containing the elements that will be used in the loop.

Output

  • Array Element: Reference to the current array element.
  • Array Index: Index of the current array element.


Example Usage

A ForEach loop is used to iterate through an array that contains the scores of the players. For each value a test is done to check whether it is the highest score, if true the value is stored in the variable "Best Score" and the player's index is stored in the variable "Best Player".

Click to enlarge


In another example, when the player overlap a Blueprint, all lamps in the Array "Lamps" will turn off except the lamp whose index is stored in the "Lamp Index to Keep On" variable.

Click to enlarge