UActorComponent::InitializeComponent
#include "Components/ActorComponent.h"
Access: public
Specifiers: virtual
Description
Called at level startup or actor spawn after registration but before BeginPlay. Override this to run initialization that requires the component to be registered with the world.
Caveats & Gotchas
- • Only called if bWantsInitializeComponent is true. You must set this flag in the constructor — it defaults to false. Forgetting to set it is a common reason why an InitializeComponent override is never called.
- • All components in the level are initialized before any component or actor receives BeginPlay. This means you can safely read other components' initialized state here, but BeginPlay-dependent systems (e.g., input, AI) are not yet available.
Signature
ENGINE_API virtual void InitializeComponent() Return Type
void Example
Override InitializeComponent to set up component state C++
UMyComponent::UMyComponent()
{
PrimaryComponentTick.bCanEverTick = true;
bWantsInitializeComponent = true; // Required!
}
void UMyComponent::InitializeComponent()
{
Super::InitializeComponent();
// Safe to access the world and registered sibling components here
CacheReferences();
} Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?