What has previously worked for me is using CreateDefaultSubobject
This way you’d get the following:
RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("OBJRoot"));
for (int32 i = 0; i < 5; i++)
{
FString j = "Mesh" + i;
CreateDefaultSubobject<UstaticMeshComponent>(FName(*j));
}
Hope this works for you too!