Referencing all array elements at one time

Take a look at this code:

for (int ta = 0; ta < Targets.Length; ta++) {
            for (float i = 0; i < tempCalculateAngleSpeed; i++) {

                Targets[ta].Rotate (0, 0, Spe);
                yield return new WaitForSeconds(Tim);

            }
        }

This will make all elements rotate, though not at the same time. After the loop of the first element finishes, the loop of the next element starts and so. I want to rotate all of the elements at the same time, not in order. Any ideas?

You’ll need to move the yield statement to another loop outside of the rotation loop, something like this:

while(true) {

    for (int ta = 0; ta < Targets.Length; ta++) {
        for (float i = 0; i < tempCalculateAngleSpeed; i++) {
            Targets[ta].Rotate (0, 0, Spe);
        }
    }
   
    yield return new WaitForSeconds(Tim);
}

(untested)

You’re code won’t do the trick. But never mind, I found the solution:

for (float i = 0; i < tempCalculateAngleSpeed; i++) {

            for (int ta = 0; ta < Targets.Length; ta++) {

                Targets[ta].Rotate (0, 0, Spe);

            }

            yield return new WaitForSeconds(Tim);
        }