Invoking a delegate function from Blueprints

Is there a way to invoke a delegate from blueprint if it is passed as a parameter to a function?

I didn’t figure out a way in BP but in C++.

Pastebin: Unreal Reactive Event - Pastebin.com


 

  1. #pragma once
  1. #include "CoreMinimal.h"
  1. #include "UObject/NoExportTypes.h"
  1. #include "ReactiveEvent.generated.h"
  1. DECLARE_DYNAMIC_DELEGATE(FReactiveEventDelegate);
  1. DECLARE_DYNAMIC_MULTICAST_DELEGATE(FReactiveEventDelegateMulti);
  1. UCLASS(Blueprintable, BlueprintType)
  1. class GRILLMASTER_API UReactiveEvent : public UObject
  1. {
  1. GENERATED_BODY()
  1. public:
  1. FReactiveEventDelegateMulti OnEventInvoked;
  1. bool bWasCalled;
  1. UFUNCTION(BlueprintCallable)
  1. void Subscribe(const FReactiveEventDelegate& callback)
  1. {
  1. OnEventInvoked.Add(callback);
  1. if(bWasCalled)
  1. {
  1. callback.Execute();
  1. }
  1. }
  1. UFUNCTION(BlueprintCallable)
  1. void OnNext()
  1. {
  1. bWasCalled = true;
  1. OnEventInvoked.Broadcast();
  1. }
  1. };

 

1 Like

The CreateEvent Node creates a delegate that can be invoked. So that would be what I would pass into the function.
I looked over all the calls that are shown in the context menu for a delegate (there aren’t many) and nothing resembles anything that might invoke the delegate.

You can take any Bind Event to XYZ node and drag a connection from the red dot to the function parameter area. This creates a generic delegate input parameter.

I went to this post when searching for this in Google, so I’m reviving it to give an answer for future.

You can invoke with time utilities function like Set Timer For Next Tick