OnComponentHit Function not working

Hello, I’m having problem with the OnComponentHit activation.

Basically I’ve written this code for my projectile class:

And this is how the OnHit function is declared and defined:

The problem is that the OnHit function is never called.

The collision settings on my projectile’s static mesh component (which is the root component and the only scene component of the actor) are the following:

And those are the collision settings of the object type “Enemy”:

In game, the only things that actually block my projectile are indeed actors with collision type of “Enemy”, but the OnHit function is never called.

Can somebody help me and tell me what I’m missing here? Thanks a lot!

Try binding in BeginPlay() instead of the constructor. For some reason the constructor doesn’t always bind to events correctly.

Hey, I have the same problem with the same class. Only, binding this event in BeginPlay vs the constructor isn’t helping.

You may be asking why the similarity - it’s because it’s a tutorial on Udemy we’re following.

My code:

Never mind, found someone that had the same issue in the tutorial forums - link here if you have the course to read it yourself.

The answer is though, close unreal editor, recompile (build) and then relaunch editor.