How do I move through an array outputting each value?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SuperSopwith

I am making an RTS and I’m currently working on formations. At the moment I have an array with positions in a formation. Each soldier in the formation is a kinematic body parented to a central kinematic body, which controls the overall movement, although the soldiers can move when changing formations. At the moment what is meant to happen is each soldier is given a position from the list. How do I make it so it cycles through all of the soldiers, giving each one a different vector from the list, instead of doing it all at once?

:bust_in_silhouette: Reply From: njamster

Iterating over an array is as simple as:

var test_array = ["One", "Two", "Three"]
for value in array:

Not sure if this solves your problem though… If not, feel free to ask in the comments.