{ }Blueprint → C++

Unreal Engine 5 · Blueprint → C++

Attach To Component in Unreal Engine 5 C++UE Docs

The Attach To Component node maps to USceneComponent::AttachToComponent, which parents one component to another using an FAttachmentTransformRules and an optional socket name.

Blueprint node & C++ equivalent

C++
MyComponent->AttachToComponent(RootComponent,
  FAttachmentTransformRules::SnapToTargetNotIncludingScale, TEXT("SocketName"));

The C++ equivalent

Call MyComponent->AttachToComponent(RootComponent, FAttachmentTransformRules::SnapToTargetNotIncludingScale, TEXT("SocketName")). The first argument is the parent to attach to, the second controls how location, rotation, and scale are handled during attachment, and the third names a socket on the parent to snap to.

SnapToTargetNotIncludingScale moves the component onto the target's transform but leaves the child's own scale untouched, which is the usual choice for weapons and equipment.

Choosing the attachment rules

FAttachmentTransformRules offers presets like KeepRelativeTransform, KeepWorldTransform, and SnapToTargetIncludingScale. Use snap-to-target when attaching to a socket and keep-world when you want the component to stay exactly where it currently is in the world.

Passing a valid socket name is what makes the component follow a specific bone or socket, such as a hand socket on a skeletal mesh.

Frequently asked questions

How do I attach a component to a socket in UE5 C++?+

Call AttachToComponent(Parent, FAttachmentTransformRules::SnapToTargetNotIncludingScale, TEXT("SocketName")), passing the socket name as the third argument.

What does SnapToTargetNotIncludingScale do?+

It snaps the component's location and rotation to the target socket but preserves the component's own scale instead of inheriting the target's scale.

Related Components nodes

View all Components nodes →