Attach child collider from code to actor

Hi!

I would like to add a simple sphere collider to my actor as a child element, all from code.

My actor’s root is a SkeletalMesh, that’s the visual representation, the sphere is the Physical one.

//header
USphereComponent* Collider;
USkeletalMeshComponent* MeshComponent;

I’ve managed to add the child sphere element, but I can’t seem to find a way to make it react to gravity and collision.

I could only make it happen with the root , mesh component, but then colliding body is not the sphere’s, but the visual mesh of my actor.

//cpp, constructor
MeshComponent	= CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("MeshComponent"));
MeshComponent->SetSimulatePhysics(true);
MeshComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Block);
MeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);

Collider = CreateDefaultSubobject<USphereComponent>(TEXT("Collider"));
Collider->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
Collider->AttachTo(MeshComponent);

I also want to listen to event’s when my character passes through the object.

How to achieve this from c++?