[UMG] Communicating from a widget blueprint to the level blueprint...

Sorry if this has been answered, I’m trying to get a button in a UMG Widget blueprint to fire a event that gets received in the level blueprint. For example the player presses a button in the Widget blueprint and a wall in-game (inside the level blueprint) gets destroyed. How can I best achieve this? How would that look in a Widget blueprint graph? How would it look inside the Level blueprint event graph? Do I use event dispatchers? Can I cast a variable to the level blueprint from the umg widget? What would be the best solution?

I’ve looked at this thread https://answers.unrealengine.com/questions/101114/fire-a-custom-event-in-a-blueprint-from-umg.html without progressing any further.

I’m on UE4 4.4.

I wouldn’t bother involving the Level blueprint.

In the Widget blueprint you can use GetAllActorsOfClass to find your wall objects and then notify them directly by casting and calling a function or event on them.

Thanks for your response,

I’ve tried the method you describe, and it would entail creating separate BP actors which act upon a custom function.

However it would be more convenient to have it called in the level blueprint to, say, trigger multiple action like say starting/stopping a matinee how would i do that?

It finds the Level blueprint however I must be doing something wrong, I get this error message:

You could use an event dispatcher on your Widget. The level BP would have to get a reference to Widget and then bind the event dispatcher to the logic you want executed.

Then inside your Widget you just have to call the event dispatcher at the right time.

I’m pretty sure that this is a bug. I get the same error message when trying to save after referencing the level blueprint from a widget blueprint.

I was under the impression that you can only event dispatch something that already exists in the level as you have to click on it to reference it in the level BP. Is this not the case?

I don’t know if Unreal 4.5 resolved some problems with the event dispatcher of widgets…but my trick works fine:

  • Go to player character blueprint and create a custom event and a event dispatcher and connect the custom event with a call of the dispatcher
  • Go to your Widget and cast the player character inside a Widget function and call a Custom event that you created earlier.
  • Finally…in your level blueprint : Begin Play cast MYCHARACTER (or your player) from Player character and assign the event dispatcher you created in the first moment.

After that you will communicate to the level Blueprint when you interact with de widget button

I agree that your best bet is to use an event dispatcher, heres a video that really helped me.

link

That was very helpful. Here are blueprint screenshots for the steps:

Please ignore the sequence player stuff as it is unrelated to the question.