OnHit not working?

Hi
I have a problem with my destructible Actor, I’m unable to bind the onHit function.

Here is the code, it is not the complete class, if you miss relevant parts please let me now.



public:
    UFUNCTION()
        void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);



CPP



void AObject::BeginPlay()
{
    Super::BeginPlay();
    GetDestructibleComponent()->OnComponentHit.AddDynamic(this, &AObject::OnHit);

   ...

}

void AObject::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
    UE_LOG(LogTemp, Error, TEXT("HITTTTTTTTTTT"));

}


I’m new to working in unreal so don’t take what I say as fact but I made a destructible actor, copied your code into it and made a blueprint from it.

It called the OnHit method when my player’s collider hit it or when my projectiles hit it but to get it to work on hits with physics events, like falling and hitting the floor, I had to add GetDestructibleComponent()->SetNotifyRigidBodyCollision(true); in BeginPlay(). Ultimately, I think the bind is correct.

@SharksArePeople2 Thanks a lot for your answer and the effort. The binding does not seems to be the problem. I think in the destructible mesh impact damage needs to be activated.