Blueprint interface functions and events

Hi!

I’m fairly new to Unreal Engine and am working on my first game using UE Blueprint programming since January. I’m using Blueprint interfaces for composition and always prefer functional programming if possible.

Using BPIs some “issues” occured making my functional programming life a little harder and browsing through the forums I was wondering if anyone else ever had the same problems and was wondering why there are some of the limitations.

  1. No pure version of BPI functions.
    Personally I use as many pure functions as possible and this actuality makes the workflow more complicated. To get a pure version of my BPI function, I can create a container function in a blueprint function library, however this leads to many functions doing the same thing and having the same name and to having to create container functions for every BPI function.

  2. BPI functions are events unless you return something.
    This seems really strange to me. There are always cases where I do not want to return anything, because the call is the end of an execution line.
    However I am forced by BPIs to return something to not have an event taking space in the event graph. Personally I try to use as less events as possible and try to keep the event graphs clean. Most events can be converted to functions via rightclick. However this does not work for BPI events.
    There is a one dirty workaround for this. First create a BPI function with return. Then write the function in your blueprint and delete the BPI return afterwards. However this means I have to do this for every implementation.

So these are the two things I wanted to address. Am I missing something here? Are BPIs not meant to be used like I am trying to do?
Sorry if a missed an already existing thread discussing this topic.

Kind regards

1 Like

I think part of the problem is wanting everything to be functions.

Technically, a function is only supposed to be used when a value is returned. And pure functions are only really pure functions when no data is changed during the process.

This is in contrast to Events ( procedures ), where data is changed, and nothing is returned.

1 Like

I agree,
however I use most of my BPI functions as pure functions to get a value that can come from a different source depending on the implementation.

For example I need to know the CurrentHealth of characters that have health. One character maybe has just a float variable in its own blueprint, another character may have an actor component containing its health, another character may have its health in a completely differenct space.
To solve this I use an interface BPI_health and let everyone implement the interface function called “health”.
(I chose health for a simple illustration of the problem, I hope you get the point)

1 Like

That sounds reasonable.

So I decided to refactor my project adapting more to the engine, instead of trying to force my own style on the engine.
I now work more with events and found two features that come in very handy for clarity in overloaded blueprints. I now create additional graphs for my different categories. Also I didnt know about “collapse nodes”. Very useful to wrap chaotic node logic. I especially use this to wrap my many interface calls to get variables from somewhere else.

Maybe this if helpful to anyone
cheers

5 Likes