Mesh doesn't follow root component

Hey guys , hope you’re fine !

I have a strange problem (maybe not , maybe i forget something) . I create a weapon class (scar) like this :

Scar.h

/** Collider and root component*/
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = sphereComponent)
	TSubobjectPtr<USphereComponent> root;

	/** SkeletalMesh of the weapon */
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = SkelMeshComponents)
	TSubobjectPtr<USkeletalMeshComponent> Mesh;

Scar.cpp

AScar::AScar(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	// Set up the sphere component as root
	root = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("SphereColl"));
	root->SetSphereRadius(0.1f);
	this->SetRootComponent(root);

	// Set up the mesh via a constructor helper
	Mesh = PCIP.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("Mesh"));
	const ConstructorHelpers::FObjectFinder<USkeletalMesh> MeshObject(TEXT("/Game/weapon/scar"));
	Mesh->SetSkeletalMesh(MeshObject.Object);
}

But when i create a blueprint derived from this class and add it on the scene , i can move the “Guizmo” but my skeletal Mesh ( the weapon) still on its place , at least i thought at the base coordinates (0,0) , and when i drag’n drop it on the scene , the mesh is directly send at theses base coordinates.

I tried by setting the mesh in the blueprint , but i had the same problem

I guess you forgot to set root as the parent of Mesh. add this line and I hope it get fixed:

Mesh->AttachParent = root;

Mesh->AttachTo(RootComponent);

What ever :stuck_out_tongue: :smiley:

I will try tomorrow , and tell you if it works

Update : it works ! , thanks
“Mesh->AttachParent = root;”

By the way , if i well understood , i can’t set the mesh as a root , i need to create a “SceneComponent” ?

it surly has to be a SceneComponent but i guess ActorComponents like Mesh are SceneComponent too.