I created an actor and added 1 mesh to it in the same way as done in Unreal Engine CPP Quick Start | Unreal Engine 5.0 Documentation. I also want to add a second static mesh, however when added, this mesh does not show up in game and is not viewable in the details box. I know that the mesh and materials are loaded correctly as the same behavior can be seen for both objects depending on which is defined first and second.
this->box = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Box"));
this->box->SetupAttachment(RootComponent);
static ConstructorHelpers::FObjectFinder<UStaticMesh> cube_asset(TEXT("/Game/StarterContent/Shapes/Shape_Cube.Shape_Cube"));
static ConstructorHelpers::FObjectFinder<UMaterial> cube_material(TEXT("/Game/mats/test.test"));
if (cube_asset.Succeeded())
{
this->box->SetStaticMesh(cube_asset.Object);
this->box->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
}
if (cube_material.Succeeded())
{
this->box->SetMaterial(0, cube_material.Object);
}
this->person = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Person"));
this->person->SetupAttachment(RootComponent);
static ConstructorHelpers::FObjectFinder<UStaticMesh> person_asset(TEXT("/Game/Scanned3DPeoplePack/RP_Character/rp_dennis_posed_004_ue4/rp_dennis_posed_004.rp_dennis_posed_004"));
static ConstructorHelpers::FObjectFinder<UMaterial> person_material(TEXT("/Game/mats/person.person"));
if (person_asset.Succeeded())
{
this->person->SetStaticMesh(person_asset.Object);
this->person->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
}
if (person_material.Succeeded())
{
this->person->SetMaterial(0, person_material.Object);
}
Interestingly, the second mesh is visible in the asset preview but not in game: