# Attach camera to socket c++

**URL:** <https://forums.unrealengine.com/t/attach-camera-to-socket-c/444048>\
**Category:** Cinematics & Media\
**Tags:** socket-reference, unreal-engine, CPP, question\
**Created:** [February 24, 2019, 4:51pm UTC](https://forums.unrealengine.com/t/attach-camera-to-socket-c/444048 "2019-02-24T16:51:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rayman30011](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rayman30011](https://forums.unrealengine.com/u/Rayman30011)\
**Post date:** [February 24, 2019, 4:51pm UTC](https://forums.unrealengine.com/t/attach-camera-to-socket-c/444048/1 "2019-02-24T16:51:05Z")

</div>

Hi! I have sample third person project. I need attach camera to skeletal mesh socket.  
I did so:

```
 FollowCamera = CreateDefaultSubobject<UCameraComponent(TEXT("FollowCamera"));
FollowCamera->SetupAttachment(GetMesh(), FName("headSocket")); 
FollowCamera->bUsePawnControlRotation = true; 

```

But it’s doesn’t working

![269473-untitled.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/1/a/41a4eff25b76b65e8abbad076e6085bf60c07f22.png)

What should I do?  
PS: I’m created socket on mesh

---

<div class="post-metadata">

**Author:** ![BenjaFriend](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BenjaFriend](https://forums.unrealengine.com/u/BenjaFriend)\
**Post date:** [February 24, 2019, 6:36pm UTC](https://forums.unrealengine.com/t/attach-camera-to-socket-c/444048/2 "2019-02-24T18:36:39Z")

</div>

If you check out [this post](https://answers.unrealengine.com/questions/355879/attach-object-to-skeletal-mesh-socket-c.html), I would try `AttatchRootComponentTo` instead of `SetupAttatchment`

---

<div class="post-metadata">

**Author:** ![Rayman30011](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rayman30011](https://forums.unrealengine.com/u/Rayman30011)\
**Post date:** [February 25, 2019, 5:52am UTC](https://forums.unrealengine.com/t/attach-camera-to-socket-c/444048/3 "2019-02-25T05:52:35Z")

</div>

I checked that post. UCameraComponent haven’t method `AttatchRootComponentTo`

---

<div class="post-metadata">

**Author:** ![BenjaFriend](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BenjaFriend](https://forums.unrealengine.com/u/BenjaFriend)\
**Post date:** [February 25, 2019, 1:57pm UTC](https://forums.unrealengine.com/t/attach-camera-to-socket-c/444048/4 "2019-02-25T13:57:38Z")

</div>

You could also try adding a `SpringArmComponent` first, and adding the camera to that. Check out the tutorial [here](https://docs.unrealengine.com/en-us/Programming/Tutorials/PlayerCamera/1)
