# How to properly attach a camera component to a socket in a character mesh?

**URL:** <https://forums.unrealengine.com/t/how-to-properly-attach-a-camera-component-to-a-socket-in-a-character-mesh/102873>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [November 20, 2017, 10:07am UTC](https://forums.unrealengine.com/t/how-to-properly-attach-a-camera-component-to-a-socket-in-a-character-mesh/102873 "2017-11-20T10:07:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tomza](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tomza](https://forums.unrealengine.com/u/Tomza)\
**Post date:** [November 20, 2017, 10:07am UTC](https://forums.unrealengine.com/t/how-to-properly-attach-a-camera-component-to-a-socket-in-a-character-mesh/102873/1 "2017-11-20T10:07:02Z")

</div>

I use in the constructor:

```auto

FPSCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FPSCamera"));
    FPSCamera->SetRelativeLocation(FVector(0.0f, -20.0f, 55.0f));
    FPSCamera->SetRelativeRotation(FRotator(0.0f, 0.0f, -90.0f));
    //FPSCamera->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetNotIncludingScale);
    FPSCamera->SetupAttachment(GetMesh());

```

And in the BeginPlay:

```auto

FPSCamera->AttachToComponent(GetMesh(), FAttachmentTransformRules(EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative, true), "FPVCamera");

```

---

<div class="post-metadata">

**Author:** ![Tomza](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tomza](https://forums.unrealengine.com/u/Tomza)\
**Post date:** [November 20, 2017, 10:09am UTC](https://forums.unrealengine.com/t/how-to-properly-attach-a-camera-component-to-a-socket-in-a-character-mesh/102873/2 "2017-11-20T10:09:42Z")

</div>

The camera component should follow the socket of the mesh. I’m unable to do that because the camera doesn’t follow the socket. I cannot parent the camera to the mesh in C++. How to do that?

---

<div class="post-metadata">

**Author:** ![Tomza](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tomza](https://forums.unrealengine.com/u/Tomza)\
**Post date:** [November 20, 2017, 11:08am UTC](https://forums.unrealengine.com/t/how-to-properly-attach-a-camera-component-to-a-socket-in-a-character-mesh/102873/3 "2017-11-20T11:08:39Z")

</div>

I use:

```auto

FPSCamera->AttachToComponent(GetMesh(), FAttachmentTransformRules(EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, EAttachmentRule::KeepRelative, true), TEXT("FPVCamera"));

```

It parents the camera to the mesh, but it is not snap to the socket - it is not moving with the socket; it is stiff.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_9cf15cf7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_9cf15cf7](https://forums.unrealengine.com/u/anonymous_user_9cf15cf7)\
**Post date:** [December 28, 2018, 7:05am UTC](https://forums.unrealengine.com/t/how-to-properly-attach-a-camera-component-to-a-socket-in-a-character-mesh/102873/4 "2018-12-28T07:05:18Z")

</div>

Did you find a way to get this to work ?
