# Loop through each index of array then perform action for each

**URL:** <https://forums.unrealengine.com/t/loop-through-each-index-of-array-then-perform-action-for-each/1250523>\
**Category:** Blueprint\
**Tags:** unreal-engine, loop, editor, Blueprint, question\
**Created:** [August 4, 2023, 11:22am UTC](https://forums.unrealengine.com/t/loop-through-each-index-of-array-then-perform-action-for-each/1250523 "2023-08-04T11:22:08Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![eleine.11](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eleine.11](https://forums.unrealengine.com/u/eleine.11)\
**Post date:** [August 4, 2023, 11:22am UTC](https://forums.unrealengine.com/t/loop-through-each-index-of-array-then-perform-action-for-each/1250523/1 "2023-08-04T11:22:08Z")

</div>

Hello!  
I just started learning UE and I ran into a problem following some tutorial (UE5.1 ver).

I have a Data Table for enemy waves (rows) containing different enemy types, each having a class and a number. The table row looks like this: ([Imgur: The magic of the Internet](https://imgur.com/5b7wiJm))

After I get the wave row, I want to go through each index and spawn the specified number of enemies of that class. At the moment, the event looks like this:

 ![waveevent](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/a/8/ca847063d047c4b1609efb1a5968a87601caf6f8.png)

In the SpawnEnemies event I also have a 1s delay for each spawn.  
It kinda works, but not quite. It simultaneously spawns 1 of each of the two enemy types, then continues to spawn the correct number for the second type.

I’ve been trying to fix it with no success. I’m guessing I have to get each index and then run the loop for each index, but can’t figure out how to do it properly… Can anyone help?

---

<div class="post-metadata">

**Author:** ![pezzott1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pezzott1/32/1215068_2.png) [@pezzott1](https://forums.unrealengine.com/u/pezzott1)\
**Post date:** [August 4, 2023, 1:15pm UTC](https://forums.unrealengine.com/t/loop-through-each-index-of-array-then-perform-action-for-each/1250523/3 "2023-08-04T13:15:54Z")

</div>

> [@eleine.11](#):
>
> In the SpawnEnemies event I also have a 1s delay for each spawn.

For loop doesn’t work well with latent nodes. You’ll need to use delays / timers if you want to spawn in intervals. Something like:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/f/1/af1a5ac283eaf1d0a463b1ab54974ac93c689e1f.png)

---

<div class="post-metadata">

**Author:** ![Dr\_Loveless](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dr_loveless/32/735613_2.png) [@Dr\_Loveless](https://forums.unrealengine.com/u/Dr_Loveless)\
**Post date:** [August 4, 2023, 1:16pm UTC](https://forums.unrealengine.com/t/loop-through-each-index-of-array-then-perform-action-for-each/1250523/4 "2023-08-04T13:16:55Z")

</div>

NOPE.

---

<div class="post-metadata">

**Author:** ![Dr\_Loveless](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dr_loveless/32/735613_2.png) [@Dr\_Loveless](https://forums.unrealengine.com/u/Dr_Loveless)\
**Post date:** [August 4, 2023, 1:17pm UTC](https://forums.unrealengine.com/t/loop-through-each-index-of-array-then-perform-action-for-each/1250523/5 "2023-08-04T13:17:22Z")

</div>

SO IF I WANTED TO TRIGGER SOMETHING TO SPAWN

I WOULD HAVE TO MAKE IT HAPPEN ON A TIMER?

WHY WOULD THAT BE CORRECT

---

<div class="post-metadata">

**Author:** ![pezzott1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pezzott1/32/1215068_2.png) [@pezzott1](https://forums.unrealengine.com/u/pezzott1)\
**Post date:** [August 4, 2023, 1:18pm UTC](https://forums.unrealengine.com/t/loop-through-each-index-of-array-then-perform-action-for-each/1250523/6 "2023-08-04T13:18:38Z")

</div>

What do you think would be a solution to the issue?

---

<div class="post-metadata">

**Author:** ![Dr\_Loveless](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dr_loveless/32/735613_2.png) [@Dr\_Loveless](https://forums.unrealengine.com/u/Dr_Loveless)\
**Post date:** [August 4, 2023, 1:20pm UTC](https://forums.unrealengine.com/t/loop-through-each-index-of-array-then-perform-action-for-each/1250523/7 "2023-08-04T13:20:31Z")

</div>

I POSTED AN ANSWER IN MY OWN WAY AND THE COMMUNITY REMOVED IT SO IM JUST HERE TO WATCH

---

<div class="post-metadata">

**Author:** ![pezzott1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pezzott1/32/1215068_2.png) [@pezzott1](https://forums.unrealengine.com/u/pezzott1)\
**Post date:** [August 4, 2023, 1:20pm UTC](https://forums.unrealengine.com/t/loop-through-each-index-of-array-then-perform-action-for-each/1250523/8 "2023-08-04T13:20:51Z")

</div>

Then just watch. 😇

---

<div class="post-metadata">

**Author:** ![Dr\_Loveless](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dr_loveless/32/735613_2.png) [@Dr\_Loveless](https://forums.unrealengine.com/u/Dr_Loveless)\
**Post date:** [August 4, 2023, 1:21pm UTC](https://forums.unrealengine.com/t/loop-through-each-index-of-array-then-perform-action-for-each/1250523/9 "2023-08-04T13:21:43Z")

</div>

OH I WAS JUST GONNA WATCH

---

<div class="post-metadata">

**Author:** ![anon42830630](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon42830630](https://forums.unrealengine.com/u/anon42830630)\
**Post date:** [August 4, 2023, 1:53pm UTC](https://forums.unrealengine.com/t/loop-through-each-index-of-array-then-perform-action-for-each/1250523/10 "2023-08-04T13:53:51Z")

</div>

Stop bothering and annoying everyone. Get away please !

---

<div class="post-metadata">

**Author:** ![Dr\_Loveless](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dr_loveless/32/735613_2.png) [@Dr\_Loveless](https://forums.unrealengine.com/u/Dr_Loveless)\
**Post date:** [August 4, 2023, 1:56pm UTC](https://forums.unrealengine.com/t/loop-through-each-index-of-array-then-perform-action-for-each/1250523/11 "2023-08-04T13:56:04Z")

</div>

NOPE WRONG

---

<div class="post-metadata">

**Author:** ![anon42830630](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon42830630](https://forums.unrealengine.com/u/anon42830630)\
**Post date:** [August 4, 2023, 1:57pm UTC](https://forums.unrealengine.com/t/loop-through-each-index-of-array-then-perform-action-for-each/1250523/12 "2023-08-04T13:57:25Z")

</div>

Wrong ?? Joke  
You’ve only been here a week and you’re annoys everyone off.  
We can’t let hate spread here.

---

<div class="post-metadata">

**Author:** ![Dr\_Loveless](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dr_loveless/32/735613_2.png) [@Dr\_Loveless](https://forums.unrealengine.com/u/Dr_Loveless)\
**Post date:** [August 4, 2023, 1:59pm UTC](https://forums.unrealengine.com/t/loop-through-each-index-of-array-then-perform-action-for-each/1250523/13 "2023-08-04T13:59:10Z")

</div>

HEY GUISE

ITS ME

IM A NERD? BUT IM FRIEKEN GOOD AT UNREAL ENGINE

SO THE ANSWER TO THIS IS THAT YOU HAVE TO SPAWN THE CHARACTER WITH TEH PLAYER CONTROLR

---

<div class="post-metadata">

**Author:** ![anon42830630](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon42830630](https://forums.unrealengine.com/u/anon42830630)\
**Post date:** [August 4, 2023, 2:03pm UTC](https://forums.unrealengine.com/t/loop-through-each-index-of-array-then-perform-action-for-each/1250523/14 "2023-08-04T14:03:47Z")

</div>

Already you write in capitals, strange.  
Bye… I won’t waste my time on these nonsense
