# OnComponentHit from capsulecomponent

**URL:** <https://forums.unrealengine.com/t/oncomponenthit-from-capsulecomponent/407741>\
**Category:** C++\
**Tags:** oncomponenthit, capsulecomponent, unreal-engine, question, CPP\
**Created:** [October 23, 2017, 5:25pm UTC](https://forums.unrealengine.com/t/oncomponenthit-from-capsulecomponent/407741 "2017-10-23T17:25:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fanzypantz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@fanzypantz](https://forums.unrealengine.com/u/fanzypantz)\
**Post date:** [October 23, 2017, 5:25pm UTC](https://forums.unrealengine.com/t/oncomponenthit-from-capsulecomponent/407741/1 "2017-10-23T17:25:22Z")

</div>

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.
