# Infinite loop error

**URL:** <https://forums.unrealengine.com/t/infinite-loop-error/2653552>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [September 4, 2025, 4:22am UTC](https://forums.unrealengine.com/t/infinite-loop-error/2653552 "2025-09-04T04:22:09Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![nande](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nande/32/1057698_2.png) [@nande](https://forums.unrealengine.com/u/nande)\
**Post date:** [September 5, 2025, 2:54am UTC](https://forums.unrealengine.com/t/infinite-loop-error/2653552/4 "2025-09-05T02:54:20Z")

</div>

grab that list of actors to spawn and save in a variable in the class. (toSpawn)

have a variable for how many actors to spawn per frame.

have a function that spawns actors (SpawnActors)

inside you loop the toSpawn array, from the last point until last+howManyPerFrame.

you spawn.

update last.

set a timer for next frame to the same SpawnActors functions.

if last \>= total then return without setting a timer.

---

_[View the full topic](https://forums.unrealengine.com/t/infinite-loop-error/2653552)._
