Dynamically added StaticMeshes not showing?

I’m using the following code to dynamically add “branches” to my dynamic “bark”. The idea is to be able to create varied foliage on the fly. The code seems to add the meshes but somehow fails to distribute them in the relative space. The image below show the visual distortion associated with overlapping geometry so this indicates all my branches are sitting at the same coordinates.

What am I doing wrong ?

AFOTBSFoliageTreeRandom::AFOTBSFoliageTreeRandom()

{
PrimaryActorTick.bCanEverTick = true;

USphereComponent* SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("RootComponent"));
RootComponent = SphereComponent;
SphereComponent->InitSphereRadius(40.0f);
SphereComponent->SetCollisionProfileName(TEXT("Bark"));
	
for (uint8 i = 0; i < 10; i++) {

	branches[i] = CreateDefaultSubobject<UStaticMeshComponent>(*(FString::Printf(TEXT("branch_%u"), i)),true);
	branches[i]->AttachTo(RootComponent);
	
	static ConstructorHelpers::FObjectFinder<UStaticMesh> SphereVisualAsset(TEXT("StaticMesh'/Game/ExampleContent/Math_Hall/Meshes/SM_Plane_100x100.SM_Plane_100x100'"));
	if (SphereVisualAsset.Succeeded())
	{
		branches[i]->SetStaticMesh(SphereVisualAsset.Object);
		float x = 30.f * i;
		float y = 0.f;
		float z = 0.f;
		branches[i]->SetRelativeLocation(FVector(x, y, z));
	}

	branches[i]->SetStaticMesh(SphereVisualAsset.Object);
	float x = 30.f * i;
	float y = 0.f;
	float z = 0.f;
	branches[i]->RelativeLocation = FVector(x, y, z);

}

}

Bump…

i think that you need to call method RegisterComponent();

	meshComponent->AttachTo(foliageActor->GetRootComponent());
	meshComponent->SetStaticMesh(MyStaticMesh);
	meshComponent->RegisterComponent();

Regards