# Spawn actor with dynamic data

**URL:** <https://forums.unrealengine.com/t/spawn-actor-with-dynamic-data/356847>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [May 8, 2016, 8:21pm UTC](https://forums.unrealengine.com/t/spawn-actor-with-dynamic-data/356847 "2016-05-08T20:21:10Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Zhi\_Kang\_Shao](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Zhi\_Kang\_Shao](https://forums.unrealengine.com/u/Zhi_Kang_Shao)\
**Post date:** [May 10, 2016, 12:08pm UTC](https://forums.unrealengine.com/t/spawn-actor-with-dynamic-data/356847/2 "2016-05-10T12:08:37Z")

</div>

Spawning an actor deferred may be what you are looking for. The normal method of spawning an actor, via UWorld::SpawnActor creates the actor and immediately initializes it, for example it calls BeginPlay() automatically. Spawning an actor deferred allows you to do dynamic stuff before the actor’s initialization is finalized. The way to do this:

- Spawn the actor with UWorld::SpawnActorDeferred()
- Do your dynamic initialization stuff here
- Call the spawn actor’s FinishSpawning function

Example code:

```
    UWorld* World = GetWorld();
	const FTransform SpawnLocAndRotation;
	AMyActor* MyActor = World->SpawnActorDeferred<AMyActor>(AMyActor::StaticClass(), SpawnLocAndRotation);
	MyActor->MySetupFunction( ... );
	MyActor->FinishSpawning(SpawnLocAndRotation);

```

Now you’re certain your dynamic values are set in time before any replication.

---

_[View the full topic](https://forums.unrealengine.com/t/spawn-actor-with-dynamic-data/356847)._
