42EspoiR
(42EspoiR)
April 21, 2015, 10:54am
1
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/index.html
**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...
Reading time: 3 mins 🕑
Likes: 8 ❤
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...
Reading time: 1 mins 🕑
Likes: 14 ❤
I have a same problem with you, can you tell me how to solve it? Thanks~
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.
zgzg2020
(zgzg2020)
September 16, 2021, 10:33am
5
How did you fix the problem?
bd0nuts
(bd0nuts)
November 9, 2023, 12:08am
6
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.
1 Like