AActor::K2_AttachRootComponentToActor
Deprecated: Use AttachToActor() instead.
#include "GameFramework/Actor.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallableUE_DEPRECATED
Description
Deprecated Blueprint-facing wrapper that attaches this actor's root component to another actor's root component. Replaced by AttachToActor() with FAttachmentTransformRules since UE 4.17.
Caveats & Gotchas
- • Deprecated since UE 4.17 — prefer AttachToActor() with explicit FAttachmentTransformRules. The old EAttachLocation enum cannot independently set Location, Rotation, and Scale behaviours.
- • Attaches to the parent actor's root component; if the parent has a custom GetDefaultAttachComponent() override, this call bypasses that override — AttachToActor() respects it.
Signature
ENGINE_API void K2_AttachRootComponentToActor(AActor* InParentActor, FName InSocketName = NAME_None, EAttachLocation::Type AttachLocationType = EAttachLocation::KeepRelativeOffset, bool bWeldSimulatedBodies = true); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InParentActor | AActor* | The actor whose root component will become the parent. | — |
| InSocketName | FName | Optional socket on the parent actor's root to attach to. | NAME_None |
| AttachLocationType | EAttachLocation::Type | How to handle the actor's existing transform when attaching. | EAttachLocation::KeepRelativeOffset |
| bWeldSimulatedBodies | bool | Whether to weld simulated physics bodies together. | true |
Return Type
void Example
Preferred modern equivalent C++
// Old (deprecated):
// ChildActor->K2_AttachRootComponentToActor(ParentActor);
// Use this instead:
ChildActor->AttachToActor(
ParentActor,
FAttachmentTransformRules::KeepRelativeTransform); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | deprecated | Deprecated since 4.17; retained for Blueprint compatibility only. |
Feedback
Was this helpful?