RealDocs

UActorComponent::RegisterComponent

function Engine Since 4.0
#include "Components/ActorComponent.h"
Access: public

Description

Registers this component with the world, creating its rendering and physics state. Also adds the component to its owner Actor's Components array if not already present.

Caveats & Gotchas

  • Must only be called when the component has a valid outer Actor that is already registered with a world; calling it on an unattached component or before the actor is spawned will assert.
  • For components created at runtime after actor spawn, you typically call RegisterComponent after AttachToComponent — failing to register leaves the component invisible and non-simulating despite being attached.

Signature

ENGINE_API void RegisterComponent()

Return Type

void

Example

Creating and registering a component at runtime C++
UStaticMeshComponent* Mesh = NewObject<UStaticMeshComponent>(this);
Mesh->SetStaticMesh(MyMesh);
Mesh->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
Mesh->RegisterComponent();

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.