# Attaching UStaticMeshComponent to Sockets Not Working

**URL:** <https://forums.unrealengine.com/t/attaching-ustaticmeshcomponent-to-sockets-not-working/468214>\
**Category:** Character & Animation\
**Tags:** socket-reference, unreal-engine, question\
**Created:** [July 15, 2020, 8:20pm UTC](https://forums.unrealengine.com/t/attaching-ustaticmeshcomponent-to-sockets-not-working/468214 "2020-07-15T20:20:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jssjogren](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jssjogren](https://forums.unrealengine.com/u/jssjogren)\
**Post date:** [July 15, 2020, 8:20pm UTC](https://forums.unrealengine.com/t/attaching-ustaticmeshcomponent-to-sockets-not-working/468214/1 "2020-07-15T20:20:35Z")

</div>

BatonHand = CreateDefaultSubobject(TEXT(“Baton Active”));  
BatonHip = CreateDefaultSubobject(TEXT(“Baton Sheath”));  
BatonHand-\>AttachToComponent(this-\>GetMesh(), FAttachmentTransformRules::SnapToTargetIncludingScale, FName(“batonhand”));  
BatonHip-\>AttachToComponent(this-\>GetMesh(), FAttachmentTransformRules::SnapToTargetIncludingScale, FName(“batonsheath”));

Does anyone know why these meshes refuse to attach to their parent sockets? I’ve checked like 8 times and the sockets exist with those exact names, and are attached to hand\_r and spine\_01 in the player’s skeletal mesh respectively.

I’m performing this in the constructor if that helps.

---

<div class="post-metadata">

**Author:** ![Crispy\_Penguin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Crispy\_Penguin](https://forums.unrealengine.com/u/Crispy_Penguin)\
**Post date:** [July 16, 2020, 1:35pm UTC](https://forums.unrealengine.com/t/attaching-ustaticmeshcomponent-to-sockets-not-working/468214/2 "2020-07-16T13:35:07Z")

</div>

Try using `SetupAttachment(GetMesh(), FName("batonhand"));` instead.

---

<div class="post-metadata">

**Author:** ![Crispy\_Penguin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Crispy\_Penguin](https://forums.unrealengine.com/u/Crispy_Penguin)\
**Post date:** [July 16, 2020, 1:37pm UTC](https://forums.unrealengine.com/t/attaching-ustaticmeshcomponent-to-sockets-not-working/468214/3 "2020-07-16T13:37:29Z")

</div>

So the update code would look like this

```
BatonHand = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Baton Active"));
BatonHand->SetupAttachment(GetMesh(), FName("batonhand"));

BatonHip = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Baton Sheath"));
BatonHip->SetupAttachment(GetMesh(), FName("batonsheath"));
```
