How to program a scene component correctly? (C++)

I would like to program a scene component that has three static meshes attached to it.

I just want to be able to handle the transformr in a simple way.
Have some code that handles dynamic materials.
And be able to attach this scene component to other actors.

I think there will be no problem with the last two objectives.

However it seems that the static meshes are not attached correctly.
I change the transform parameters and it doesn’t affect the meshes (as you can see in this video).

This is the code:


.H

TestComponent.h (1.1 KB)


UCLASS(Blueprintable, meta=(BlueprintSpawnableComponent))
class UTestComponent : public USceneComponent
{
	GENERATED_BODY()

	UPROPERTY(EditDefaultsOnly)
	class UStaticMeshComponent *Mesh1=nullptr;

	UPROPERTY(EditDefaultsOnly)
	class UStaticMeshComponent *Mesh2=nullptr;

	UPROPERTY(EditDefaultsOnly)
	class UStaticMeshComponent *Mesh3=nullptr;

public:
	UTestComponent(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());

protected:

	virtual void BeginPlay() override;
	virtual void OnRegister() override;
};

.CPP
TestComponent.cpp (1.8 KB)


UTestComponent::UTestComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
	PrimaryComponentTick.bCanEverTick = true;

	AActor* MyOwner = GetOwner();
	if (!IsValid(MyOwner)) return;	

	Mesh1 = NewObject<UStaticMeshComponent>(MyOwner, FName("MSH1"));
	if (!IsValid(Mesh1)) return;
	Mesh1->SetupAttachment(this);
	Mesh1->SetIsVisualizationComponent(true);

	Mesh2 = NewObject<UStaticMeshComponent>(MyOwner, FName("MSH2"));
	if (!IsValid(Mesh2)) return;
	Mesh2->SetupAttachment(this);
	Mesh2->SetIsVisualizationComponent(true);	

	Mesh3 = NewObject<UStaticMeshComponent>(MyOwner, FName("MSH3"));
	if (!IsValid(Mesh3)) return;
	Mesh3->SetupAttachment(this);
	Mesh3->SetIsVisualizationComponent(true);	
}

I used this as a guide:

Does anyone know how to do this correctly?

Thank you so much!!