Detect collision in a custom actor class

I have a custom class inheriting Actor and try to execute some code when it collides with an object. The Actor has a permanent movement and I want to flip its direction on collision.

In the docs I found OnActorHit but I fail to understand how to bind it to my Class.

Based on the answers of this question I tried to override it, but it doesn’t seem part of the actor class and thus can’t be overwritten.
Then I tried the following inside my class constructor:

FScriptDelegate Delegate;
Delegate.SetFunctionName(TEXT("OnActorHit"));
Delegate.SetObject(this);
this->OnActorHit.AddUnique(Delegate);

and somewhere later the method

void ACustomClass::OnActorHit()
{
    LOG("Collision detected");
}

but the line this->OnActorHit.AddUnique(Delegate); seems to fail because it’s expecting a struct and this is my custom class instance.

I have a blueprint based on my custom class that I want to use, I don’t create an instance of it anywhere else.

How can I bind a method to an event when collision happens?

I have the same problem maybe you can take a look here https://answers.unrealengine.com/questions/22891/how-to-useread-api-doc-c.html . Two persons gave me two different way to do it , but at the moment i haven’t succeeded to make it work .

FScriptDelegate Delegate;
Delegate.SetFunctionName(TEXT(“Hit”));
Delegate.SetObject(this);
ArrowCaps->OnComponentBeginOverlap.AddUnique(Delegate);
(arrowCaps is the capsule component )

void AArrow::Hit()
{
	
	GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Yellow, TEXT("touch !"));
}

I tried this but it change nothing :frowning:

Try without delegate. Like this:

ArrowCaps->OnComponentBeginOverlap.AddDynamic(this, &AArrow::Hit);
ArrowCaps->OnComponentEndOverlap.AddDynamic(this, &AArrow::Hit);

And “Hit” function need have this signature:

Hit(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)

Or if You use OnActorHit function looks:

Hit
(
    class AActor * SelfActor,
    class AActor * OtherActor,
    FVector NormalImpulse,
    struct FHitResult Hit,
)

I came here trying to achieve the excact same thing.
Is there a solution to this? There seems to be no way to find out the correct signature of the handler function. I suppose the business with the structs is something that is supposed to be hidden by the reflection magic, right?

Anyway… Is there any answer to this yet?