# Children of my custom USceneComponent do not use parents transform

**URL:** <https://forums.unrealengine.com/t/children-of-my-custom-uscenecomponent-do-not-use-parents-transform/2310475>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [January 30, 2025, 3:49pm UTC](https://forums.unrealengine.com/t/children-of-my-custom-uscenecomponent-do-not-use-parents-transform/2310475 "2025-01-30T15:49:44Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Dakxon2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dakxon2](https://forums.unrealengine.com/u/Dakxon2)\
**Post date:** [January 31, 2025, 9:24am UTC](https://forums.unrealengine.com/t/children-of-my-custom-uscenecomponent-do-not-use-parents-transform/2310475/2 "2025-01-31T09:24:49Z")

</div>

I have found the answer to my problem in this post:

> [@UE5 Template Mismatch During Attaching of Instanced Component](https://forums.unrealengine.com/t/ue5-template-mismatch-during-attaching-of-instanced-component/1510733):
>
> Hello Unreal Engine Community, I’m encountering a problem with my Unreal Engine 5 project and could really use some help. I have a Blueprint named BP\_VRPawn which is derived from a C++ class AVRPawn. The main issue is that the Skeletal Mesh representing the hands is not being attached to the MotionControllers. Another issue is that the first time I open the folder containing BP\_VRPawn, or the first time I open the Blueprint itself, the Visual Studio debugger stops, and I receive the following l…

My understanding of the problem is as follows:

In the constructor of my `UCameraMovementComponent` I set attachement to `this`:

```auto
UCameraMovementComponent::UCameraMovementComponent()
{
	PrimaryComponentTick.bCanEverTick = true;
	PrimaryComponentTick.SetTickFunctionEnable(true);

	mesh_ = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
	mesh_->bAutoActivate = true;
	mesh_->bAutoRegister = true;
	mesh_->SetupAttachment(this);
}

```

When the CDO of my class is constructed, `this` is pointing to the CDO and not the specific instance of my class. Since `mesh_` is a UPROPERTY it will be get replaced in the actual instance after construction with the version from the CDO. This means my class instance has a `mesh_` that is attached to the CDO, and not my instance.

To Solve this issue I need to reattach the `mesh_` to the correct parent when the component is registered (after the CDO values are copied)

```auto
void UCameraMovementComponent::OnRegister() {
    Super::OnRegister();
    this->mesh_->AttachToComponent(this, FAttachmentTransformRules::KeepRelativeTransform);
}

```

With this addition the component works as expected.

---

_[View the full topic](https://forums.unrealengine.com/t/children-of-my-custom-uscenecomponent-do-not-use-parents-transform/2310475)._
