How to use the different DECLARE_DELEGATE C++?

The only delegate I got to work was DECLARE_DYNAMIC_MULTICAST_DELEGATE: and I even found that intellisense doesnt tell you that AddDynamic() works with it, and I understand that you can only bind functions that have UFUNCTION() above them. Im trying to mix and match the different DECLARE_DELEGATEs, trying to test Broadcast() and Execute(), but I fail to get a successful compile with binding the functions to the delegates.

To simplify any explanation, I want to know how to use different DECLARE_DELEGATES without parameters; Just call a void UFUNCTION. How do you utilize the different DECLARE_DELEGATEs? How do you bind them? How do you make them call the binded functions?

to invoke a function with no params is just

DECLARE_DYNAMIC_MULTICAST_DELEGATE

you declare it in the .h file after the includes like this:

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FFire);

then you must make a variable of thed type of the delegate:

UPROPERTY()
FFire fireDisPatcher;

and then bind a function like this:

fireDisPatcher.AddDynamic(this, &&myActor::firefunction);

then to invoke is just

firedispatcher.Broadcast();

firefunction is just a simple function like:

void myActor::firefunction()
{
something;
}

Hope it helps! :slight_smile:

Thanks, but DECLARE_DYNAMIC_MULTICAST_DELEGATE(FDelegateName) was the only one I figured out, and almost every tutorial I could find uses it, and not any other version.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.