[Blueprints] How to add delegate parameter to interface function?

Hi

We are trying to move our implementation to the “Implement to interfaces” paradigm, where everything is an implementation on an interface

Interfaces cannot have “event dispatchers”, so we tried to pass the event to function in the interfaces then bind it in the implementation as we can do in normal class function
Unfortunately, we could not do that, we cannot define an interface function parameter of type “delegate”

In a class, I can create a normal function that take an event as a parameter and bind it to a dispatcher, I cannot make this an interface function as I do not know how to define it in the interface

Thanks

If it is not possible, Is it a feature or a bug?

Don’t think it’s possible without a plugin or C++

Not everything implemented in C++ has been exposed to blueprint. This just hasn’t been done…

Are you against plugins? There’s a good one that allows you to trigger any event with just an actor ref:

Thanks for your suggestion

I am not generally against plugins, but this is a feature that will reside in the foundation code, it has to be a core engine feature.

also, I saw the demo video and it does not seem to have the required feature (delegate as interface function parameter)

To be fair, delegates are not the same as interfaces :slight_smile:

( They have a different use ).

We also need Interfaces that support implementing delegates.

Any luck finding out how to do this in a generic way? (that also supports Blueprints)

This might be an old thread but wanted to document how I’ve achieved a solution for a similar problem:

Problem

We were developing a system of minigames, which included some events sensitive to the minigame information (OnClose, OnClompeted, OnFail, etc…)

This needed to be an interface, as parenting UI widgets was not an option at the time.
This lead to the error: we can’t have neither Delegate parameters nor EventDispatchers on interfaces (and for other reasons, C++ wasn’t an option)

Solution

We’ve created an Object type class called MinigameDelegates where we can specify any event we would want.
Then, on the interface itself, we’ve implemented GetMinigameDelegates which return this very object for any other class that need this info.

The only downside is that we need to make an Valid check on each one of the classes that implements our interface, but this surely was a backdrawn we were willing to take

There is no straightforward solution I can think of in C++ either to support this in blueprints. If you try to use an event delegate as a function parameter for your interface and make that function BlueprintCallable, you’ll get slapped with the following compiler error:

Type 'YourEventDelegate' is not supported by blueprint.