Multi mesh actor with several hit boxes

I want to build a simple actor with 2 cube meshs and track the hits on each cube.

When creating a new Actor based class, with 2 UStaticMeshComponent variables

.h file:

public:	
    UPROPERTY(VisibleAnywhere)
    UStaticMeshComponent* cube0;
    
    UPROPERTY(VisibleAnywhere)
    UStaticMeshComponent* cube1;

.cpp file:

// within the constructor function
cube0 = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("cube0"));
cube1 = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("cube1"));

this actually crushes unreal editor (latest), can an actor have 2 static mesh components?

How can I create an actor with 2 mesh objects?
How should I implement the two different hit boxes for the two components?

You need to attach the components to the root or another component.

cube0->SetupAttachement(RootComponent);
 cube1->SetupAttachement(RootComponent);

Also, what does the crash log say?

Thanks @Takao_ attachments to a RootComponent solved the issue, what about hit detection on each cube? cube0-?OnComponentHit.AddDynamic() doesnt seem to do much

In order to get hit events you need to set the components to generate them and also specifiy against which object and trace channels they should generate those events.

Adding a function (dynamic) to OnComponentHit or OnActorHit is also require if you want to use C++ functions.