Description
Completes the deferred spawning process by running construction scripts and finalizing the actor's state. Must be called exactly once for every actor spawned with bDeferConstruction = true.
Caveats & Gotchas
- • Calling FinishSpawning more than once on the same actor is an error and will trigger an ensure. The engine tracks whether it has already been called via an internal flag.
- • If you forget to call FinishSpawning on a deferred actor, the actor will exist in the world but BeginPlay will never fire and components will not be properly initialized.
Signature
ENGINE_API void FinishSpawning(const FTransform& Transform, bool bIsDefaultTransform = false, const FComponentInstanceDataCache* InstanceDataCache = nullptr, ESpawnActorScaleMethod TransformScaleMethod = ESpawnActorScaleMethod::OverrideRootScale) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Transform | const FTransform& | The final world transform to apply to the actor. | — |
| bIsDefaultTransform | bool | If true, the transform is treated as a default that can be overridden by template values. | false |
| InstanceDataCache | const FComponentInstanceDataCache* | Optional cache of component instance data to restore (used for re-running construction scripts). | nullptr |
| TransformScaleMethod | ESpawnActorScaleMethod | How to resolve scale conflicts between the spawn transform and the actor's template. | ESpawnActorScaleMethod::OverrideRootScale |
Return Type
void Example
Deferred spawn: set properties then finish C++
FActorSpawnParameters Params;
Params.bDeferConstruction = true;
AMyActor* Actor = GetWorld()->SpawnActor<AMyActor>(AMyActor::StaticClass(), SpawnTransform, Params);
if (Actor)
{
Actor->InitialColor = FLinearColor::Red;
Actor->FinishSpawning(SpawnTransform);
} Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?