Firing multiple different projectiles with delay

Hello there,

I am trying to build a vampire survivors clone in unreal engine but I am struggling with the main aspect of the game: shooting a lot of projectiles :slight_smile:
I currently have 3 different type of projectiles and each projectile type can level up. With each level one additional projectile will be fired of that type. So if skill 1 is level 6 it would fire 6 projectiles.
But I dont want to fire them all at once but rather with a short delay of 0,1 sec. And that is where the issues come in. I learned already that I am not allowed to have a delay in a for loop. And I also saw the workarounds where you are supposed to build your own for loop macro which includes a delay. Unfortunately this does not work for me. I have the feeling UE is overwhelmed as I want to spawn all actors at once.

Here I am iterating through a data table and trigger each ability listed in it:

Here I am triggering the selected ability:

And here I am spawning the number of projectiles with the loop with delay macro:

Currently the result is only one of the three abilities fires the correct amount of projectiles. All other two abilities are only fired off once. Which seems very strange to me. I hope someone can help me because I have no clue what else to do.

I think this loop is the issue, try using the loop with break and break so you stop processing other entries, alternatively move this BP to a function and once you call the shoot projectile function add a return node so the function exist and aborts the loop.

Edit here’s an example of the ForEach with break

1 Like

Thanks Kaidoom15 for your reply! But I still dont understand on what condition I should break. When I am done shooting projectiles for one type? So what is the underlying issue here? That the loop overwrites the previous entries?

Use tiemr to loop, this is my thought. Hope it can help you

The ForEach loop will run in one frame essentially, it does not care about the delay in the macro and so it will go over all elements in the data table and call ShootProjectile all of that in one frame.

Check out the description of the delay node

I’m not sure what QuerySkill does but you can reduce the two calls to one call, by passing the SkillLevel to ShootProjectile and from it to the macro, this way you don’t need to call QuerySkill again to get the index since you already got it.