[Feature Request] Anonymous functions/callbacks as a parameter on Blueprints

Hey everyone,

I saw several other people creating threads like this, and I thought I am allowed as well (am I?). Sorry if I’m doing it wrong.

So, Epic, PLEASE!, allow us to pass (anonymous) functions/events as parameters of other functions through Blueprint. I know it’s possible to do it through C++ (everything’s possible with it), but people oftentimes neither are using it in their projects (not directly, you know), or they have no knowledge to do it (my case).


I’m gonna use my use-case as an example.

It’s a multiplayer game that is always transporting payloads throughout the whole game’s lifecycle. I’m trying to make all the client-stuff as stateless as possible to avoid inconsistencies, but oftentimes I stumble upon tiny things like the need to clone an array or execute a function for each element of another array; Blueprints, unfortunately, lack these abilities natively, not to mention that by design, it is completely stateful.

To fill these “gaps” Blueprints currently have, I thought to create my own utility belt (also using BPs). But geez, another problem!

Let me show you a function I was creating:

To give you some context: this Clone Array function was created inside a Function Blueprint, which is supposed to be available everywhere (because I do have the need to use it very often.).

The very first problem was to choose the type of the Array argument. I’ve chosen Object, then. Very vague, but it worked. And it’s fine because I understand C++ is strongly-typed by design.

Moving further, with the New Array in hands, I felt the need to cast it to the proper type I wanted. And here’s where my issue sleeps.

In order to cast every element on New Array to the proper type, I thought to create a ForEachLoop doing the cast thing for me. But then I stopped and thought: if I had to do this every time I wanted to clone an array, then argh, the function Clone Array would be more a pain than a solution.

Suddenly another idea just sparked in my head!

Create a function called Map Array, which takes two arguments: Array and Callback.

  • Array: the array that’d be iterated;
  • Callback: an event/function that’d do something with every element of the Array.

After running the passed function on every element of the array, I wanted to create a new array, keeping the indices as the same as in the first argument, but with the mutated values (outputted by the callback function, passed in the second argument).

Well, not possible. Not now, not without C++.

I know there’re some complications here regarding design and architecture and it’s not just a “let’s do it!”, but I have the impression that Blueprints lack features for immutability–which would increase reliability and consistency of data transportation in multiplayer games.

Finally, a question I’d like to leave here: Blueprints are stateful and object-oriented by design. How can I make those Blueprint Function Library useful?

That’s it. Thanks.