Is it possible to pass functions as references in blueprints?

Relatively new to blueprints, trying to avoid c++

I’m creating a basic interaction system where when you walk up things, the ui displays a description of what you can do, and if you press a button, it’ll do that action. What I would ideally like to be able to do is, every tick, set a variable to record the correct display text, and set a variable to the correct function to run if the button is pressed, like a delegate or a first class function.

It seems to me the above is not possible. One alternative could be returning an index to use in a select statement to determine what function top run when the button is pressed, but that sounds gross to me. Am I correct that the above is not possible? If not, is there a better way to approach this problem?

I’ve seen other discussions about doing this with C++ delegates, but would prefer to avoid those.

For the bucket, with BP interfaces, you would make the events ‘Put in’, ‘Hold’ and ‘Take out’. They can be used with the bucket, but also with all other blueprints you have. And their meaning, and the code used is different for every type of blueprint.

You might want to look into Event dispatchers as well. I find between Interfaces & Event dispatchers you have enough flexibility to do just about anything you need.

You’re looking for interfaces:

This is useful, but I’m not sure what I need. At a glance, interfaces solve the problem of wanting to call a version of a function from different objects. What I’m dealing with is dealing with the fact that any given object might have multiple ways to interact with it, and I don’t want to run the same conditional logic twice to figure out what the function and descriptor should be.

E.g. a bucket might let you put something in it if you’re holding something, or take something out if you’re not.

Yes this is what I was looking for. Interfaces are good if you have generic functions you expect to apply to many different item. Event dispatchers look like they’ll be handier for many things with unique functionality. I find their implementation to be kind of unintuitive but I’ve got it working as I’d hoped. Thanks!

Hey I just came across this info today and figured I would pass it along. This has a great breakdown of the different ways to use event dispatchers.

https://forums.unrealengine.com/development-discussion/blueprint-visual-scripting/72814-event-dispatchers-explained-finally