OnComponentHit from capsulecomponent

I’m trying to get the OnComponentHit from the capsulecomponent in ACharacter but I only seem to be able to do it in blueprints.

This is what I have now:

// PlayerCharacter.h	
void OnComponentHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit);


// APlayerCharacter::APlayerCharacter()
GetCapsuleComponent()->bGenerateOverlapEvents = true;
GetCapsuleComponent()->SetNotifyRigidBodyCollision(true);
GetCapsuleComponent()->OnComponentHit.AddDynamic(this, &APlayerCharacter::OnComponentHit);

I’ve tried googling this, but I can’t find anything this specific, I might just suck at googling though. What I have seem like it should work on any kind of shape, but I imagine there is something special about the capsulecomponent in ACharacter.