Delegate is only being called once

For my project, I have a damageable component that I want to call whenever I want an actor to take damage (I’m Aware of Apply Damage). I want this function to be changeable depending on what actor is using the DamageableComponent. Delegates seem to be what I need to accomplish this. I’ve created a very basic example based on the post below.

https://forums.unrealengine.com/t/tutorial-creating-and-using-delegates-c-and-accessing-them-in-blueprints/9649

In my actor blueprint, I bind this example event on BeginPlay and print out the damage value passed to it. The issue occurs that for the first shot that hits the character the event is called successfully and the damage is printed out. However, the event will not successfully be called again. You can see some of my implementation below.

Declaration

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FExampleDelegate_OnSomething, float, _exampleEventParameter);

UPROPERTY(BlueprintAssignable)
		FExampleDelegate_OnSomething ExampleDelegateVariable;

Implementation

DamageableComponent->ExampleDelegateVariable.Broadcast(1000);

Screenshot_1426

It seems like after the event has succeeded the event is being unbound from the function. Which doesn’t seem like the correct behavior to me. If I call Bind on Tick instead of BeginPlay it works as expected, however, that also doesn’t seem like the correct behavior. In the engine source, I have tried placing breakpoints on every remove trying to figure out when/where it may have been removed however none of them were hit.

Any insight would be appreciated :slight_smile:

use Interfaces :face_in_clouds:

1 Like

It can be done with interfaces but I want to use delegates. Unreal themselves are using delegates for their ApplyDamage/TakeDamage functions. I found a couple of videos/tutorials on them and everything I do seems to be correct.

I just don’t understand why my function seems to be getting unbound after the first call.

The problem seems to be with the node function of binding/adding the delegated function.

Under my Damageable Component, there is an event with my delegate name, and using this event directly is working as intended rather than binding on beginplay.