# Delay in the MIDDLE of a for loop

**URL:** <https://forums.unrealengine.com/t/delay-in-the-middle-of-a-for-loop/1889139>\
**Category:** Blueprint\
**Tags:** delay, foreachloop, timer, unreal-engine, Blueprint, CPP, question\
**Created:** [June 4, 2024, 2:08pm UTC](https://forums.unrealengine.com/t/delay-in-the-middle-of-a-for-loop/1889139 "2024-06-04T14:08:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Izuuubito](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Izuuubito](https://forums.unrealengine.com/u/Izuuubito)\
**Post date:** [June 4, 2024, 2:08pm UTC](https://forums.unrealengine.com/t/delay-in-the-middle-of-a-for-loop/1889139/1 "2024-06-04T14:08:59Z")

</div>

SO I HAVE BUMPED INTO A HURDLE

I want to execute a for loop with a delay, which isnt apparently possible by default. I know I could make a new macro, but here is a problem: I dont want the delay be at the beginning or ending of the loop body - but in the middle of it.

AS in

For each item in array  
{  
//execute some code  
Delay 5 seconds  
//execute some code  
}

How can I do this?

Blueprints preferred, but if C++ is needed to solve this, I will welcome a C++ solution

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [June 4, 2024, 2:47pm UTC](https://forums.unrealengine.com/t/delay-in-the-middle-of-a-for-loop/1889139/2 "2024-06-04T14:47:05Z")

</div>

I’m pretty sure you can do that with a macro

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/c/1/3c120e63d947dacc746c906ffa8cdc98a55603e2.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/3/e/33e2f91f730612411309e9c7f0313df5e8f14b57.png)

But… It will not wait until ‘part 1’ is done before executing the delay, and it will not wait until ‘part 2’ is done before running the next index.

If you want it to wait for everything, then you just have to make a manual loop

---

<div class="post-metadata">

**Author:** ![Izuuubito](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Izuuubito](https://forums.unrealengine.com/u/Izuuubito)\
**Post date:** [June 7, 2024, 7:47am UTC](https://forums.unrealengine.com/t/delay-in-the-middle-of-a-for-loop/1889139/3 "2024-06-07T07:47:48Z")

</div>

I ended up doing just that 🙂 Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [July 7, 2024, 7:48am UTC](https://forums.unrealengine.com/t/delay-in-the-middle-of-a-for-loop/1889139/4 "2024-07-07T07:48:00Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
