# Cannot get into NotifyHit function

**URL:** <https://forums.unrealengine.com/t/cannot-get-into-notifyhit-function/325564>\
**Category:** World Creation\
**Tags:** notify, unreal-engine, Collision, UE4, question, CPP\
**Created:** [July 17, 2015, 12:58am UTC](https://forums.unrealengine.com/t/cannot-get-into-notifyhit-function/325564 "2015-07-17T00:58:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_942ec4a21](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_942ec4a21](https://forums.unrealengine.com/u/anonymous_user_942ec4a21)\
**Post date:** [July 17, 2015, 12:58am UTC](https://forums.unrealengine.com/t/cannot-get-into-notifyhit-function/325564/1 "2015-07-17T00:58:38Z")

</div>

I am trying to get a function to call in my pawn class whenever my pawn bumps into something or hits it. (It’s going to damage the ships shields based on how hard I hit an object.)

I am using a pawn with the starter content UFO guy for now as I get the game working.

I am trying to simply override the NotifyHit function Here’s what I’ve got:

In the Pawn’s header:

```
	UFUNCTION()
		virtual void NotifyHit(class UPrimitiveComponent* MyComp, AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit) override;

```

In the Cpp:

```
void ATestPawn::NotifyHit(class UPrimitiveComponent* MyComp, AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit)
{
	GEngine->AddOnScreenDebugMessage(1, 15.0f, FColor::Red, "I am being notified of a hit.");
}

```

I do not get into this function at all.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_942ec4a21](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_942ec4a21](https://forums.unrealengine.com/u/anonymous_user_942ec4a21)\
**Post date:** [July 17, 2015, 1:05am UTC](https://forums.unrealengine.com/t/cannot-get-into-notifyhit-function/325564/2 "2015-07-17T01:05:56Z")

</div>

I forgot to mention but I DO have the following line in the pawn’s constructor:  
SetActorEnableCollision(true);

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_942ec4a21](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_942ec4a21](https://forums.unrealengine.com/u/anonymous_user_942ec4a21)\
**Post date:** [July 17, 2015, 2:04am UTC](https://forums.unrealengine.com/t/cannot-get-into-notifyhit-function/325564/3 "2015-07-17T02:04:45Z")

</div>

On the Root Mesh Component I had to enable the following settings.

```
PawnMeshComponent->SetNotifyRigidBodyCollision(true);

```

I should point out that This C++ variable corresponds to a bool in the editor named: Simulation Generates Hit Events. One of these names should probably be updated to more appropriately reflect the other.

Thank you.

---

<div class="post-metadata">

**Author:** ![Ch3shireCat](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ch3shireCat](https://forums.unrealengine.com/u/Ch3shireCat)\
**Post date:** [February 2, 2017, 9:46pm UTC](https://forums.unrealengine.com/t/cannot-get-into-notifyhit-function/325564/4 "2017-02-02T21:46:09Z")

</div>

Thanks, it actually solved my problems.

---

<div class="post-metadata">

**Author:** ![Calcifer\_1996](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Calcifer\_1996](https://forums.unrealengine.com/u/Calcifer_1996)\
**Post date:** [December 19, 2023, 8:42pm UTC](https://forums.unrealengine.com/t/cannot-get-into-notifyhit-function/325564/5 "2023-12-19T20:42:50Z")

</div>

Finally solved for me, thanks!  
staticMesh-\>SetNotifyRigidBodyCollision(true) worked for me too!

Really irritates me the lack of documentation UE has, you end up getting stuck on simple problems.
