AActor::AddComponent

Creates a new component and assigns ownership to the Actor this is called for.

Windows
MacOS
Linux

Syntax

UActorComponent * AddComponent
(
    FName TemplateName,
    bool bManualAttachment,
    const FTransform & RelativeTransform,
    const UObject * ComponentTemplateContext
)

Remarks

Creates a new component and assigns ownership to the Actor this is called for. Automatic attachment causes the first component created to become the root, and all subsequent components to be attached under that root. When bManualAttachment is set, automatic attachment is skipped and it is up to the user to attach the resulting component (or set it up as the root) themselves.

Parameters

Parameter

Description

TemplateName

The name of the Component Template to use.

bManualAttachment

Whether manual or automatic attachment is to be used

RelativeTransform

The relative transform between the new component and its attach parent (automatic only)

ComponentTemplateContext

Optional UBlueprintGeneratedClass reference to use to find the template in. If null (or not a BPGC), component is sought in this Actor's class

See Also

UK2Node_AddComponent DO NOT CALL MANUALLY - BLUEPRINT INTERNAL USE ONLY (for AddComponent nodes)

References

Module

Engine

Header

Runtime/Engine/Classes/GameFramework/Actor.h

Source

Runtime/Engine/Private/ActorConstruction.cpp

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback