# Why is SetupAttachment not working as expected?

**URL:** <https://forums.unrealengine.com/t/why-is-setupattachment-not-working-as-expected/403412>\
**Category:** C++\
**Tags:** sockets, third-person-templat, attachment, unreal-engine, UE4, CPP, question\
**Created:** [August 31, 2017, 8:46pm UTC](https://forums.unrealengine.com/t/why-is-setupattachment-not-working-as-expected/403412 "2017-08-31T20:46:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jurplel](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jurplel](https://forums.unrealengine.com/u/jurplel)\
**Post date:** [August 31, 2017, 8:46pm UTC](https://forums.unrealengine.com/t/why-is-setupattachment-not-working-as-expected/403412/1 "2017-08-31T20:46:19Z")

</div>

I am trying to attach the camera boom from the third person C++ template to the character’s head. I created a socket called “firstperson”, and changed the code to the following:

```
CameraBoom->SetupAttachment(GetMesh(), TEXT("firstperson"));

```

I had trouble getting it attached to anything at first, but at some point it attached to the mesh properly, but it still won’t attach to the socket. Can someone please tell me what i’m doing wrong? I can’t find anything on this.

---

<div class="post-metadata">

**Author:** ![jurplel](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jurplel](https://forums.unrealengine.com/u/jurplel)\
**Post date:** [September 5, 2017, 3:16am UTC](https://forums.unrealengine.com/t/why-is-setupattachment-not-working-as-expected/403412/2 "2017-09-05T03:16:08Z")

</div>

I have fixed it by using AttachToComponent in BeginPlay

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_65a9ba941](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_65a9ba941](https://forums.unrealengine.com/u/anonymous_user_65a9ba941)\
**Post date:** [September 13, 2017, 3:30am UTC](https://forums.unrealengine.com/t/why-is-setupattachment-not-working-as-expected/403412/3 "2017-09-13T03:30:20Z")

</div>

Thank you very much for this post. I spent almost an hour wondering why my components were not following their mesh!

---

<div class="post-metadata">

**Author:** ![jurplel](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jurplel](https://forums.unrealengine.com/u/jurplel)\
**Post date:** [September 13, 2017, 3:02pm UTC](https://forums.unrealengine.com/t/why-is-setupattachment-not-working-as-expected/403412/4 "2017-09-13T15:02:00Z")

</div>

No problem, glad I could help!
