PostInitializeComponents() vs BeginPlay()

PostInitializeComponents() is called when the object is created and all of it’s components have been registered and initialized. It’s a good place to do setup because you know it’s called as soon as the actor is ready to be used and called before any networking operations have run. Bear in mind that this will also run when the object is opened in a blueprint editor for example, so sometimes you may need to filter out what you’re doing with a simple check:



const UWorld* lWorld = GetWorld();
if (lWorld && lWorld->IsGameWorld())
{
    // Do game setup
}


BeginPlay() is called at varying times depending on the environment and networking setup. In my experience it’s more reliable to do setup in PostInitComps, as you know exactly when it’s called.

12 Likes