How do we listen for a Blueprint Implementable event in C++?

Inside of my Character.h, I have the following code:


UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnWeaponFire"))
		void OnEventFire();

It’s an event that is called from my C++ code like so:


OnEventFire();

It’s picked up in blueprints:

So it works perfectly, and everything is fine. But I want to know how I can execute code in C++ in the same way it is executed in blueprints. So basically, when I call the event inside of my C++ code, it is picked up inside of blueprints and the nodes are executed. When the event is called, I want to be able to listen to it from other C++ classes (or even the same class). When I call “OnEventFire();”, I want another class to be able to execute code if that event is called.

I know I can use delegates, but they’re confusing in the sense that I don’t understand how I can listen for them. I create the delegate, then the signature, and even broadcast it, but I don’t know how I can listen to the event from other classes.

1 Like

You have to use a delegate to get that to work. If you make the delegate a public variable, you should be able to just call DelegateName.Bind( callback ). Look here: Delegates | Unreal Engine Documentation

But I’m not looking to create a method that can be called from anywhere. I want to create an event that I can broadcast and have any class listening for it to execute code if the event is fired. Like with blueprints: I call the OnEventFire() method from C++, and blueprints executes code when it’s called. I want to be able to do the same with C++, where calling OnEventFire() will execute code in a completely different class.

Essentially, I have tried using delegates but I don’t understand how I’m suppose to listen for a delegate event when it is broadcasted.