# Attach component to actor socket

**URL:** <https://forums.unrealengine.com/t/attach-component-to-actor-socket/486278>\
**Category:** C++\
**Tags:** attach-to-actor, unreal-engine, question, CPP\
**Created:** [July 16, 2021, 2:27am UTC](https://forums.unrealengine.com/t/attach-component-to-actor-socket/486278 "2021-07-16T02:27:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lucas\_Mondini](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/lucas_mondini/32/88717_2.png) [@Lucas\_Mondini](https://forums.unrealengine.com/u/Lucas_Mondini)\
**Post date:** [July 16, 2021, 2:27am UTC](https://forums.unrealengine.com/t/attach-component-to-actor-socket/486278/1 "2021-07-16T02:27:11Z")

</div>

i’m trying to attach a sword to my player but it isn’t getting the socket’s name, it’s attaching to the root bone

```
void ABaseWeapon::pickUpWeapon(AThirdPersonCharacter* player) {
	weaponMesh->SetSimulatePhysics(false);
	RootComponent->SetUsingAbsoluteRotation(false);
	FName socket = "DefaultWeapon_back";
	this->AttachToActor(player, FAttachmentTransformRules::SnapToTargetNotIncludingScale, socket);
}

```

 ![344235-ue4root2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/a/8/1a81fe540ab7ced2426bf6f8cd1a9e6cc63d898e.jpeg)

alt text

---

<div class="post-metadata">

**Author:** ![Tuerer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tuerer/32/1008648_2.png) [@Tuerer](https://forums.unrealengine.com/u/Tuerer)\
**Post date:** [July 18, 2021, 8:18am UTC](https://forums.unrealengine.com/t/attach-component-to-actor-socket/486278/2 "2021-07-18T08:18:25Z")

</div>

Actors don’t have sockets, meshes do. If you take a look at the AttachToActor() implementation, you’ll see that underneath there’s an AttachToComponent() function that attaches to the DefaultAttachComponent; I think in your case the DefaultAttachComponent is not the Skeletal Mesh, but probably the RootComponent? And it doesn’t have any sockets.

First of all, see which component is returned by the GetDefaultAttachComponent() function. Then you can carry on from that.
