RealDocs

APawn::PreInitializeComponents

function Engine Since 4.0
#include "GameFramework/Pawn.h"
Access: public Specifiers: virtualoverride

Description

Called before component initialization begins. APawn uses this to set up AI controller auto-possession when AutoPossessAI is configured for spawn-time possession.

Caveats & Gotchas

  • Always call Super::PreInitializeComponents() first, or auto-possession logic will silently break.
  • This fires before BeginPlay and before components register — do not attempt to access component state or call functions that depend on initialized components here.

Signature

virtual void PreInitializeComponents() override;

Return Type

void

Example

Override to configure pre-init state C++
void AMyPawn::PreInitializeComponents()
{
	Super::PreInitializeComponents();
	// Set up data that must exist before components initialize
	MyData = CreateDefaultSubobject<UMyDataComponent>(TEXT("MyData"));
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.