# Spawning with c++ causes a ton of lag 

**URL:** <https://forums.unrealengine.com/t/spawning-with-c-causes-a-ton-of-lag/2653714>\
**Category:** C++\
**Tags:** unreal-engine, question, Blueprint, CPP\
**Created:** [September 4, 2025, 5:55pm UTC](https://forums.unrealengine.com/t/spawning-with-c-causes-a-ton-of-lag/2653714 "2025-09-04T17:55:16Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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, 3:39am UTC](https://forums.unrealengine.com/t/spawning-with-c-causes-a-ton-of-lag/2653714/2 "2025-09-05T03:39:17Z")

</div>

> [@Infinite loop error](https://forums.unrealengine.com/t/infinite-loop-error/2653552/4):
>
> 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/spawning-with-c-causes-a-ton-of-lag/2653714)._
