Arrays are powerful but also super annoying. I just started to work with them more, and here's what I learned. The Resident Array Expert is DjayDino
You can add to an array with Array Add. To get something from an array, you can use Array Get Next. To create this, you must make a small loop.
You need a central state with array next with two events,
loop and
done. You also need
reset bool (you can of course name them however you want). Fill out the array next (you probably don't need to store the index). It will leave through
loop where it grabs the next item from the array list, where you can then do your stuff on that item. Then finish the state back to the central array get next state, where it grabs the next item of the array and so on. Until it's done (when it goes to the
done event).
Since you want to reset this after each loop, you place a Set Bool
reset to false, in the state after
loop (where you handle one individual item). And in the state after done, Set Bool
reset to true. So next time, it will restart the loop fresh.
Another important and very pesky thing about arrays is that they can easily trip up when a particular index (one place in the array list) is empty. You can clean this out with array concatenate (from ecosystem). And if you want to renew the entire array, you also need to deliberately array clear and array resize it (to default). Otherwise, if you always add, the arrays becomes a giant list that is empty (arrays can contain "null" entries). If for some reason an array item disappears during the process, you might want to throw in a
game object is null action in the state after loop, and somewhere on top, so it skips whatever you do there.