# BroadCast event cpp not call my function

**URL:** <https://forums.unrealengine.com/t/broadcast-event-cpp-not-call-my-function/315813>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [April 21, 2015, 10:54am UTC](https://forums.unrealengine.com/t/broadcast-event-cpp-not-call-my-function/315813 "2015-04-21T10:54:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![42EspoiR](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@42EspoiR](https://forums.unrealengine.com/u/42EspoiR)\
**Post date:** [April 21, 2015, 10:54am UTC](https://forums.unrealengine.com/t/broadcast-event-cpp-not-call-my-function/315813/1 "2015-04-21T10:54:31Z")

</div>

Hi dear UE community,

Edit: It works now, my problem was elsewhere.

I’m trying to use MultiCast Delegate to fire an event the same way as OnComponentHit works for collision.

I have declared a Delegate in my file AShip.h:

```
USTRUCT(BlueprintType)
struct FDamageStruct
{
};
...
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnDamageTaken, const FDamageStruct&, Damage);
...

```

In my class:

```
UPROPERTY(BlueprintAssignable, Category = "Damage")
	FOnDamageTaken OnDamageTaken;

```

in my file AShip.cpp

```
OnDamageTaken.Broadcast (damage);

```

On an another class i register a function to this event with:

Skill.cpp:

```
MyShip->OnDamageTaken.AddDynamic(this, &ASkill::OnShipDamageTaken);

```

with Skill.h

```
UFUNCTION()
    void OnShipDamageTaken(const FDamageStruct& Damage);

```

My problem is:

During execution time my function OnShipDamageTaken is never call.

If I check the variable OnDamageTaken i see my function is registered.

Does anyone know why my function could not be called ?

Thx

References:

[https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Delegates/Multicast/index.html](https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Delegates/Multicast/index.html)

[https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Delegates/index.html](https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Delegates/index.html)

> **[\[Tutorial\] Creating and Using Delegates C++ and Accessing them in Blueprints](https://forums.unrealengine.com/showthread.php?30345-Tutorial-Creating-and-Using-Delegates-C-and-Accessing-them-in-Blueprints)**
>
> \*\*Before we start: \*\* A disclaimer I do not pretend to be an expert but i do my best in trying. So if any mistakes are made in this tutorial I please let me know so I can fix them that and feedback in general is much aprichiated. What will we...

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

---

<div class="post-metadata">

**Author:** ![42EspoiR](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@42EspoiR](https://forums.unrealengine.com/u/42EspoiR)\
**Post date:** [April 21, 2015, 3:34pm UTC](https://forums.unrealengine.com/t/broadcast-event-cpp-not-call-my-function/315813/2 "2015-04-21T15:34:10Z")

</div>

I mark it as Solved

---

<div class="post-metadata">

**Author:** ![Alan\_Walk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alan\_Walk](https://forums.unrealengine.com/u/Alan_Walk)\
**Post date:** [May 12, 2015, 3:20am UTC](https://forums.unrealengine.com/t/broadcast-event-cpp-not-call-my-function/315813/3 "2015-05-12T03:20:22Z")

</div>

I have a same problem with you, can you tell me how to solve it? Thanks~

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b67fa2a5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b67fa2a5](https://forums.unrealengine.com/u/anonymous_user_b67fa2a5)\
**Post date:** [November 19, 2015, 11:43pm UTC](https://forums.unrealengine.com/t/broadcast-event-cpp-not-call-my-function/315813/4 "2015-11-19T23:43:34Z")

</div>

I was wondering the same thing, but then I realized AddDynamic() _was_ calling my delegate on Broadcast(). The breakpoint in my delegate was skipped because I compiled with the “Development Editor” config and the empty call was optimized-out.

---

<div class="post-metadata">

**Author:** ![zgzg2020](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zgzg2020](https://forums.unrealengine.com/u/zgzg2020)\
**Post date:** [September 16, 2021, 10:33am UTC](https://forums.unrealengine.com/t/broadcast-event-cpp-not-call-my-function/315813/5 "2021-09-16T10:33:31Z")

</div>

How did you fix the problem?

---

<div class="post-metadata">

**Author:** ![bd0nuts](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bd0nuts](https://forums.unrealengine.com/u/bd0nuts)\
**Post date:** [November 9, 2023, 12:08am UTC](https://forums.unrealengine.com/t/broadcast-event-cpp-not-call-my-function/315813/6 "2023-11-09T00:08:18Z")

</div>

For people stumbling on this post years later, as i did:  
The answer is to put the macro UFUNCTION() in front of the functions that are getting called by the broadcast.
