# Component won't attach to SkeletalMesh socket

**URL:** <https://forums.unrealengine.com/t/component-wont-attach-to-skeletalmesh-socket/385459>\
**Category:** Character & Animation\
**Tags:** sockets, attach, unreal-engine, skeletalmesh, question\
**Created:** [February 19, 2017, 8:39pm UTC](https://forums.unrealengine.com/t/component-wont-attach-to-skeletalmesh-socket/385459 "2017-02-19T20:39:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juice-Tin](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/juice-tin/32/1008648_2.png) [@Juice-Tin](https://forums.unrealengine.com/u/Juice-Tin)\
**Post date:** [February 19, 2017, 8:39pm UTC](https://forums.unrealengine.com/t/component-wont-attach-to-skeletalmesh-socket/385459/1 "2017-02-19T20:39:23Z")

</div>

Hello, I’ve got a skeletal mesh called Mesh and a weapon called WeaponMesh  
I’m trying to attach the WeaponMesh to a socket called ‘Weapon’ inside the skeletalmesh.  
(Note this has to be done in code, you can’t attach inherited objects inside the editor)

Here is my code in the constructor:

```
WeaponMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("WeaponMesh"));
WeaponMesh->SetupAttachment(Mesh, FName("Weapon"));

```

![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/8/3/a83e9bc2f9d55f132bdb0d5f918a1551848e6930.png)

You can see the WeaponMesh gets added to the mesh just fine, but if you look at the properties… it’s not added to the socket:

![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/b/2/8b21c5f53845a0e0d800186f322275ac9d1a55ef.png)

To test, I added a SkeletalMesh (shown above) within the editor. That one attaches to the socket just fine:

![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/3/c/03cda15e3cc3d54aeb2b353446c7bef2468292f8.png)

Why won’t this get added through code? I’m done it many other times and it’s always worked, but this particular one just won’t attach for some reason. Is it because it’s a Skeletalmesh being attached to a socket? Is this a bug?

---

<div class="post-metadata">

**Author:** ![staticvoidlol](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@staticvoidlol](https://forums.unrealengine.com/u/staticvoidlol)\
**Post date:** [February 20, 2017, 2:03pm UTC](https://forums.unrealengine.com/t/component-wont-attach-to-skeletalmesh-socket/385459/2 "2017-02-20T14:03:34Z")

</div>

Maybe some things to check:

- That the socket can actually be found through code (e.g. use Mesh-\>DoesSocketExist(FName(“Weapon”))
- That the attachment code has already executed when you look at the blueprint? Not quite sure here, but if it’s not in the constructor then that code wouldn’t have run yet.
- Maybe it’s just a display bug in the editor?

---

<div class="post-metadata">

**Author:** ![Juice-Tin](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/juice-tin/32/1008648_2.png) [@Juice-Tin](https://forums.unrealengine.com/u/Juice-Tin)\
**Post date:** [February 21, 2017, 7:13pm UTC](https://forums.unrealengine.com/t/component-wont-attach-to-skeletalmesh-socket/385459/3 "2017-02-21T19:13:25Z")

</div>

Thanks for the suggestions staticvoidlol.

I solved it by removing the Weapon code completely, compiling, and then adding it back in.  
Looks like unreal wasn’t updating the fact that I attached it to a mesh, so completely removing it and placing it back with the attachment in place did the job.

---

<div class="post-metadata">

**Author:** ![morceli](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@morceli](https://forums.unrealengine.com/u/morceli)\
**Post date:** [December 28, 2018, 7:22am UTC](https://forums.unrealengine.com/t/component-wont-attach-to-skeletalmesh-socket/385459/4 "2018-12-28T07:22:35Z")

</div>

This is pretty weird but we are almost in 2019 and the problem still there.

tyvm btw.

---

<div class="post-metadata">

**Author:** ![theRPGmaster](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/therpgmaster/32/1139086_2.png) [@theRPGmaster](https://forums.unrealengine.com/u/theRPGmaster)\
**Post date:** [September 18, 2019, 8:51pm UTC](https://forums.unrealengine.com/t/component-wont-attach-to-skeletalmesh-socket/385459/5 "2019-09-18T20:51:22Z")

</div>

Thank you, worked for me on 4.23

---

<div class="post-metadata">

**Author:** ![Awakatoso](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Awakatoso](https://forums.unrealengine.com/u/Awakatoso)\
**Post date:** [November 19, 2021, 4:16pm UTC](https://forums.unrealengine.com/t/component-wont-attach-to-skeletalmesh-socket/385459/6 "2021-11-19T16:16:14Z")

</div>

It worked for me too on 4.24.3

---

<div class="post-metadata">

**Author:** ![elguapador](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@elguapador](https://forums.unrealengine.com/u/elguapador)\
**Post date:** [January 25, 2023, 12:18pm UTC](https://forums.unrealengine.com/t/component-wont-attach-to-skeletalmesh-socket/385459/7 "2023-01-25T12:18:55Z")

</div>

What eventually worked for me was one or more of the following:

- Unset and reset character mesh in BP
- Change attached mesh variable and display name
- Comment out SetupAttachment code, compile, start engine, quit, uncomment

Annoying bug
