How to bind a function to OnActorHit?

I’m trying to define a function that will be called when my actor collides with another actor. My code is like this
In Character constructor:


BindDynamic(OnActorHit, OnMyActorHit);

OnMyActorHit definition:


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

When I try to compile it says __Internal_BindDynamic is undefined
I also have Delegate.h included in my cpp file
I’m not sure if this is the right way to do this. Any suggestions?

Hi Conda,

The first argument to BindDynamic is the object you want to bind on, try using it like this:


OnActorHit.BindDynamic(this, &UYourClassName::OnMyActorHit);

Cheers,
Michael Noland

Thanks. I tried that but an error is still being shown: FActorHitSignature has no member __Internal_BindDynamic

I looked into this briefly but couldn’t figure it out either nor is this topic covered on the Wiki

For now you could modify the source to call the subclass til we learn the ‘proper’ way this is handled. Luckily, I do not need this event myself atm

Yea that works for the moment but it will get tedious when I want to set each event function for multiple character so I’m gonna wait for an official answer. Thanks anyway.


TriggerBox->OnComponentBeginOverlap.AddDynamic(this, &AHidingSpot::ActorEntersTrigger);
TriggerBox->OnComponentEndOverlap.AddDynamic(this, &AHidingSpot::ActorLeavesTrigger);

That is how i used it. OnActorHit delegate is also dynamic multicast, so i guess it should work.

Thanks BiggestSmile, that does indeed work



OnActorHit.AddDynamic(this, &AMyCharacter::OnMyActorHit);
AMyCharacter::OnMyActorHit(AActor* SelfActor, AActor* OtherActor, FVector NormalImpulse, const FHitResult& Hit)


2 Likes