Download

Function Naming Confusion When Add Dynamic On Multicast Delegates

Hi all,
When we are using a function to overlap we have code line like :

MeshComp->OnComponentBeginOverlap.AddDynamic(this, &AWeapon::AnyNamedStuff)

AWeapon::AnyNamedStufffunction can be named anything and its working.

Then for that purpose, I have created DECLARE_DYNAMIC_MULTICAST_DELEGATE in my component to handle damage.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_SixParams(FOnHealthChangedSignature, UHealthComponent*, HealthComp, float, Health, float, HealthDelta, const class UDamageType*, DamageType, class AController*, InstigatedBy, AActor*, DamageCauser)

FOnHealthChangedSignature OnHealthChanged

When I add healthcomponent to my class I need to bind exactly with the same function name in my class. I wonder WHY ?

HealthComponent->OnHealthChanged.AddDynamic(this, &ASCharacter::OnHealthChanged);

If I change to
HealthComponent->OnHealthChanged.AddDynamic(this, &ASCharacter::AnyName);
Its not working

You are probably missing the UFUNCTION specifier on your AnyName function. Post your header file if that is not it.

Compile will throw error if I would not have it on my header file.

ASCharacter::AnyName probably don’t have the correct signature (parameters) like ASCharacter::OnHealthChanged do.