# Async spawn objects

**URL:** <https://forums.unrealengine.com/t/async-spawn-objects/323497>\
**Category:** Blueprint\
**Tags:** async, threading, unreal-engine, UE4, Blueprint, question, CPP\
**Created:** [June 29, 2015, 10:35pm UTC](https://forums.unrealengine.com/t/async-spawn-objects/323497 "2015-06-29T22:35:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hjeldin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@hjeldin](https://forums.unrealengine.com/u/hjeldin)\
**Post date:** [June 29, 2015, 10:35pm UTC](https://forums.unrealengine.com/t/async-spawn-objects/323497/1 "2015-06-29T22:35:45Z")

</div>

Hello,  
i’m trying to spawn 1k to 10k objects onscreen (mostly billboards) which are recovered from an external network service on a different thread.

When the thread completes the download it calls a blueprint-implemented delegate, which then cycles through the objects to spawn and actually spawns it.

My main issue is that with this number of objects, the engine struggles (it freezes for 10 or more seconds before actually displaying the billboards).

Is there a way to asynchronously spawn objects from blueprint OR c++?

Thanks,  
Riccardo.

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [June 30, 2015, 12:57am UTC](https://forums.unrealengine.com/t/async-spawn-objects/323497/2 "2015-06-30T00:57:10Z")

</div>

Here you have tutorial how to create your own threads in C++:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

You need to keep in mind using multithreading on unprepared code for that might be risky and unstable and i don’t know if spawning code is ready for it. So do a lot of testing.

---

<div class="post-metadata">

**Author:** ![hjeldin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@hjeldin](https://forums.unrealengine.com/u/hjeldin)\
**Post date:** [June 30, 2015, 1:08am UTC](https://forums.unrealengine.com/t/async-spawn-objects/323497/3 "2015-06-30T01:08:21Z")

</div>

I already have a multithread architecture, the issue is that it can’t manipulate scene objects (or something that’s owned by the graphics thread); that’s the reason I spawn objects from a blueprint event that’s called from the main thread.

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [June 30, 2015, 1:44am UTC](https://forums.unrealengine.com/t/async-spawn-objects/323497/4 "2015-06-30T01:44:25Z")

</div>

Then there no way or else you revamp whole spawning code if multithreading does not work. Or maybe try to hide those 10 seconds of frezee

---

<div class="post-metadata">

**Author:** ![Bennicus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bennicus](https://forums.unrealengine.com/u/Bennicus)\
**Post date:** [June 30, 2015, 4:40pm UTC](https://forums.unrealengine.com/t/async-spawn-objects/323497/5 "2015-06-30T16:40:05Z")

</div>

Could you spawn this large pool of objects on startup, put them in a threadsafe / lockless queue or something, and then when you need them you can have multiple worker threads pop these already-constructed objects from the queue and initialise them with the appropriate state?

---

<div class="post-metadata">

**Author:** ![hjeldin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@hjeldin](https://forums.unrealengine.com/u/hjeldin)\
**Post date:** [July 1, 2015, 2:24pm UTC](https://forums.unrealengine.com/t/async-spawn-objects/323497/6 "2015-07-01T14:24:45Z")

</div>

I’m in the process of trying this approach.  
I just tried using a Gameplay Timer and handling there the spawning of new objects, but after 400/500 elements the framerate just drops to 1/2 fps and goes back to 60 after it reached 1k and stops.

---

<div class="post-metadata">

**Author:** ![hjeldin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@hjeldin](https://forums.unrealengine.com/u/hjeldin)\
**Post date:** [July 10, 2015, 7:26pm UTC](https://forums.unrealengine.com/t/async-spawn-objects/323497/7 "2015-07-10T19:26:23Z")

</div>

Turns out that initializing thousands of objects with a sphere collider in the same position is really BAD.

Spawning them in a random box was the solution, since it now only takes a second or two.
