Download

Communication between Widget and Level Blueprint

Hi,

I have button in widget and after click I want to get variables to level blueprint.

I have tried many options but still didn’t found what I need.

I used MainMode BP_MainGameMode and I added Variables DisplayWidget

  1. option:

2. option:

I need to get variable after click button in widget to level blueprint.

Have you set the project ( or level ) to use that game mode?

GM.JPG

I added now in GameMode override and this is my code:
It’s not happening nothing…

I want to go back in m_MainMenu level and then from widget click button to blueprint level, like that:

Meh… I think you’re mixing up event dispatchers and blueprint interfaces there.

Can you just explain what you’re trying to do?

I have Widget with one button. I want to click on button (**Button_93 **in my case )and open level **m_MainMenu **and in **m_MainMenu **I want to get variable from Widget button.

So, this is how to do what you’re trying to do. You are having problems for a couple of reasons:

  1. The level BP isn’t really designed to be talked to from outside.

  2. Everybody has problems with dispatchers in the beginning

The widget:

](filedata/fetch?id=1810418&d=1599814538)

Level BP of the level -before- you call your level:

](filedata/fetch?id=1810419&d=1599814586)

Level BP of m_MainMenu:

](filedata/fetch?id=1810420&d=1599814657)

I used to game instance to pass the variable, it’s the logical choice. The game mode is actually there to choose your configuration of controller, player, etc. But it doesn’t really matter, it works in exactly the same way.

I will also do ( in a little while ) an example of how I would do this, because trying to talk to the level BP is like pulling teeth, as you can see :wink:

Right, easy version :slight_smile:

Make a blueprint interface, call it MyBPI. It has one function ‘LoadLevel’:

The starting level doesn’t need anything in the level BP.

The game instance ( or mode if you’re using that ):

Notice how the GI is subscribed to the blueprint interface, so it can implement the call.

The widget:

Notice how the widget has to cast the GI to put the variable in, but what’s cool is that it doesn’t need to cast to send the load level message ( see it’s using the uncast connection ). That’s because blueprint interface messages can be sent to any actor.

So, the widget sends the interace message to the GI ( or game mode etc ), that triggers the event which loads the level.

thanks it works!