AActor::PostSpawnInitialize
#include "GameFramework/Actor.h"
Access: public
Description
Called immediately after the actor is spawned in the world. Sets up ownership, instigator, and optionally runs construction scripts. This is an engine-internal function called by UWorld::SpawnActor — do not call it directly.
Caveats & Gotchas
- • This is called by UWorld::SpawnActor and must not be called manually; incorrect parameters can leave the actor in a partially initialized state.
- • When bDeferConstruction is true, the actor will be in an unusable state until FinishSpawning is explicitly called. Accessing components or properties between PostSpawnInitialize and FinishSpawning is unsafe.
Signature
ENGINE_API void PostSpawnInitialize(FTransform const& SpawnTransform, AActor* InOwner, APawn* InInstigator, bool bRemoteOwned, bool bNoFail, bool bDeferConstruction, ESpawnActorScaleMethod TransformScaleMethod = ESpawnActorScaleMethod::MultiplyWithRoot) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| SpawnTransform | FTransform const& | The world transform at which the actor should be spawned. | — |
| InOwner | AActor* | The actor to assign as the Owner of this actor. | — |
| InInstigator | APawn* | The pawn responsible for spawning this actor. | — |
| bRemoteOwned | bool | Whether the actor is owned by a remote connection. | — |
| bNoFail | bool | Whether spawning should be forced even if checks fail. | — |
| bDeferConstruction | bool | Whether to defer running the construction script until FinishSpawning is called. | — |
| TransformScaleMethod | ESpawnActorScaleMethod | How to apply scale when combining actor template scale with the spawn transform. | ESpawnActorScaleMethod::MultiplyWithRoot |
Return Type
void Example
Deferred spawn pattern requiring PostSpawnInitialize awareness C++
FActorSpawnParameters Params;
Params.bDeferConstruction = true;
AMyActor* Actor = GetWorld()->SpawnActor<AMyActor>(AMyActor::StaticClass(), SpawnTransform, Params);
if (Actor)
{
// Safe to set properties here before construction scripts run
Actor->MyProperty = SomeValue;
Actor->FinishSpawning(SpawnTransform);
} See Also
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?