Since components can't handle blueprint implementable events how should i implement an event for a condition triggered by my component?

Did you find a solution to this limitation? Eg, is there a way of exposing to BP a delegate or event?

This is the solution I have found, which isn’t ideal but does work. Basically the component exposes a method to BP that takes a delegate and binds it to a event. You can then trigger then event using Broadcast. Its a bit backward (and the BP setup is a bit fidly) so if there is a better solution I would really like to see it.

Declare the delegate

UDELEGATE(BlueprintType, Category = Delegate)
DECLARE_DYNAMIC_DELEGATE(FEventResponder);

This allows your method to accept a delegate as a parameter. Note it must be a dynamic delegate.

Make the event

DECLARE_EVENT(UCurfewTerminalHackableComponent, FCurfewEvent);
FCurfewEvent OnCurfewActivated;

This is just a normal C++ event, you can read more about them in the [documentation for events][1]. To trigger it, you just call OnCurfewActivated.Broadcast()

Create the Bind method

In your component you want a method that looks something like:

 UFUNCTION(BlueprintCallable, Category = DelegateBinder)
 void AddOnCurfewActivatedResponder(FEventResponder Responder);

Which has the following implementation:

void UCurfewTerminalHackableComponent::AddOnCurfewActivatedResponder(FEventResponder Responder)
{
    OnCurfewActivated.AddUFunction(Responder.GetUObject(), Responder.GetFunctionName());
}

Now, when you trigger OnCurfewActivated, the function passed in to the responder will be called.

Adding the method in BP

In the BP with the component in, create a new EventDispatcher.

In the Event Graph, drag the dispatcher on and choose event. This will give you a node with an execution pin (which you can use to get whatever you want to happen to happen) and a red square shaped pin.

Create an Event Begin Play node and call the AddOnCurfewActivatedResponder method on the component. Pass in the event (using the red square). Now when you broadcast your event, the execute pin on the event node will be triggered.

11586-bindexample.png

Improvements
Apart from just being able to use BlueprintImplementableEvents on components, this method would be improved if could be done in the construction (rather than on begin play). Better yet would be just exposing the event to BP and having a BP method to add so one doesn’t have to write a Bind method for each event.

Its not like components cant handle ikplementable events, implemantable events is based on function overriding, as it using standard function call it can be used only localy inside the local class. If you want event that can lbe isten outside a class, you need to set up delegate, i wrote how to do this here:

Remeber to add BlueprintAssignable wpecifier to malendelegate accessable via blueprint

Oh you been faster, but i bet you be interested in what i posted :wink:

True, but since you can’t make a BP that derives from a component, there is no way in BP to override the method. So the question of how to trigger some blueprint script from a component is valid.

Your answer I think is better than mine since doesn’t involve writing a method! I shall try it out now

I tried it out and it worked. Thanks for the help.