RealDocs

AActor::OnConstruction

function Engine Since 4.0
#include "GameFramework/Actor.h"
Access: public Specifiers: virtual

Description

Called when an instance of this class is placed in the editor or spawned at runtime, after native components are created but before BeginPlay. Use for editor-time procedural setup driven by actor properties.

Caveats & Gotchas

  • OnConstruction can be called multiple times in the editor whenever actor properties are changed — your implementation must be idempotent and handle repeated calls without leaking components or resources.
  • Do not spawn other actors or perform world-modifying operations in OnConstruction during editor-time calls; the world may not be fully loaded and undo/redo can leave orphaned objects.
  • Unlike BeginPlay, OnConstruction runs in the editor. Code inside it should not assume gameplay systems (game mode, timers, etc.) are available.

Signature

virtual void OnConstruction(const FTransform& Transform) {}

Parameters

Name Type Description Default
Transform const FTransform& The transform the actor was constructed at.

Return Type

void

Example

Procedural mesh generation in editor C++
void AMyProceduralActor::OnConstruction(const FTransform& Transform)
{
	Super::OnConstruction(Transform);
	// Regenerate procedural mesh based on current property values
	ProceduralMesh->ClearAllMeshSections();
	GenerateMesh();
}

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.