Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

BroadCast event cpp not call my function

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:

 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:


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

with Skill.h

     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 ?







Product Version: Not Selected
more ▼

asked Apr 21 '15 at 10:54 AM in C++ Programming

avatar image

293 11 8 20

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I mark it as Solved

more ▼

answered Apr 21 '15 at 03:34 PM

avatar image

293 11 8 20

avatar image Alan Walk May 12 '15 at 03:20 AM

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

avatar image tigercrab Nov 19 '15 at 11:43 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question