Event which connects 2 blieprints?

Hello,

I have a widget and I click on a button there.
I would like it triggers an event in the main blueprint.

Please let me know How to do it?
What event should I use in the main blueprint and how to triger it in the widget blueprint?

Thanks,
Alex

So, firstly, decide how to get a reference of blueprint you want to trigger. Pass as an exposed on spawn variable, get from player pawn/controller or something else. Secondly, create a custom event in main blueprint. Thirdly, in widget create an OnButtonPressed binding, where you’ll call a custom event from main blueprint reference.

1 Like

you’re looking for Event Dispatchers | Event Dispatchers / Delegates Quick Start Guide

  1. Create widget in main blueprint and store it in a variable (if you already have a reference to the widget, use that instead).
  2. Create an Event dispatcher in your widget blueprint
  3. Call it when you click the button

image

  1. In the main blueprint, drag from the widget variable and call bind action to [Event Dispatcher Name]
  2. Drag from the little red square pin in the bind node and create a custom event.

image

that custom event will get called every time you click the button
(the button text input won’t be there in the custom event, it’s just how it’s setup in the random dispatcher I chose to screenshot!)

1 Like

Hello, Thank you very much for the reply. Could you let me know please, how to store a whole widget blueprint in a variable?

And also, what if I created widget bleprints not into the main blueprint. Unfortunately I don’t know how to create it into the main blueprint. I just clicked on the button (create event) into the widget and it opens me a certain blueprint and it is not the main one.

Thanks.

if you’re creating the widget through blueprints using “Create widget” node, you can right click on the return value pin and promote it to a variable.

image

OR

if you’re creating the widget using the designer by dragging and dropping, then a variable will be automatically created for you with the same name.

Thank you very much for the reply! Yes it indeed already has a variable, but I can’t drag and drop in into another - main blueprint. It says: Cannot place a variable ‘House’ in external scope ‘EventGraph’.

can you share a screenshot of the main blueprint and the widget blueprint

Yes, here it is:

ok, so that’s just the variable for the button, we need a variable for the widget itself.

how are you showing the widget on screen?

Here is how I show it:

1 Like

Ok, Right click on the Return Value pin on the “Create Widget Teleport Menu widget” node and select promote to variable.

1 Like

Thank you Extrone for your help.
Unfortunately I’ve probably done something wrong. Please take a look at these blueprints:

Oh, that’s my bad. You need to connect the Execute pin [White pin] of the bind node after add to viewport.

EDIT : you don’t have to directly connect the blue wire from the set node, you can use the variable instead.

Yeah, now everything works correctly. Thank you Extrone, God bless you. :slight_smile: You very helped.
It was pretty difficult for a begginer like me.

1 Like

That’s great, glad I could help :smile:

1 Like