# How to get ChildComponent use RootComponents animation?

**URL:** <https://forums.unrealengine.com/t/how-to-get-childcomponent-use-rootcomponents-animation/396874>\
**Category:** Character & Animation\
**Tags:** child-actor-componen, skeletalmeshcomponen, unreal-engine, question\
**Created:** [July 2, 2017, 2:51pm UTC](https://forums.unrealengine.com/t/how-to-get-childcomponent-use-rootcomponents-animation/396874 "2017-07-02T14:51:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![VadersApp](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@VadersApp](https://forums.unrealengine.com/u/VadersApp)\
**Post date:** [July 2, 2017, 2:51pm UTC](https://forums.unrealengine.com/t/how-to-get-childcomponent-use-rootcomponents-animation/396874/1 "2017-07-02T14:51:36Z")

</div>

Spend the whole day for finding a solution for my proplem, but haven´t any luck to get this working.

A **BodyComponent** (USkeletalMeshComponent) having the mesh and the animation is working fine. I now want to attach another component to it as a dummy **UClothesComponent** (USkeletalMeshComponent) which should hold an TArray of SkeletalMeshComponents for clothing. Clothing is added to the body and moving with it, but clothes never get animation. I think thats because animation of BodyComponent is not transferred to UClothesComponent, which has no skeletal data, so that the clothes even don´t get animation data.

If i would attach one of the clothes directly to BodyComponent it is being animated and synched to the body animation. So my question is: What i am missing here? Is there a better way, a working one, to have a clean component-structure and ChildComponents being animated with the a ParentComponent?

Code of the Female.cpp file

```
	BodyComponent = ObjectInitializer.CreateDefaultSubobject<UFemaleBodyComponent>(this, TEXT("BodyComponent"));
	BodyComponent->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepWorldTransform);
	BodyComponent->SetMobility(EComponentMobility::Movable);
	BodyComponent->SetWorldRotation(RotateOffset);
	BodyComponent->SetRelativeLocation(FVector(0.0f, 0.0f, -90.0f));
	BodyComponent->bDisableMorphTarget = false;
	
	
	ClothesComponent = ObjectInitializer.CreateDefaultSubobject<UClothesComponent>(this, TEXT("ClothesComponent"));

	ClothesComponent->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepWorldTransform);
	ClothesComponent->SetMobility(EComponentMobility::Movable);
	ClothesComponent->SetWorldRotation(RotateOffset);
	ClothesComponent->SetRelativeLocation(FVector(0.0f, 0.0f, -90.0f));
	ClothesComponent->bDisableMorphTarget = false;

```

Code of the UClothesComponent.cpp

```
UClothesComponent::UClothesComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
	PrimaryComponentTick.bCanEverTick = true;
	int counter = 0;
	for (auto temp : UGarments::ArrGarments)
	{
		counter++;
		GarmentComponents.Add(ObjectInitializer.CreateDefaultSubobject<USkeletalMeshComponent>(this, *FString("Cloth" + FString::FromInt(counter))));
	}
	for (int i=0; i<counter;i++) {
	ConstructorHelpers::FObjectFinder<USkeletalMesh> Asset(*UGarments::ArrGarments[i].Path);
	if (Asset.Succeeded())
	{
		GarmentComponents[i]->SetSkeletalMesh(Asset.Object);
	}

	GarmentComponents[i]->AttachToComponent(this, FAttachmentTransformRules::KeepWorldTransform);
	GarmentComponents[i]->SetMobility(EComponentMobility::Movable);
	}
```

---

<div class="post-metadata">

**Author:** ![VadersApp](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@VadersApp](https://forums.unrealengine.com/u/VadersApp)\
**Post date:** [July 3, 2017, 4:32pm UTC](https://forums.unrealengine.com/t/how-to-get-childcomponent-use-rootcomponents-animation/396874/2 "2017-07-03T16:32:53Z")

</div>

Found the solution and its very simple. I had to add “ClothesComponent-\>SetMasterPoseComponent(BodyComponent);”
