How to use a 3D widget component to affect the level blueprint?

Hi All,

I’m trying to make an interactive computer screen element in my game, and I’ve used 3D widgets to act as the terminal displays. The problem I have is - how do I get button events in the widget blueprint to affect the level? I want the player to be able to press a button whilst possessing the terminal, and have it turn on a light. I basically just want to get the widget button to affect the level blueprint.

Here is what I have so far. I have a Pawn Blueprint called ‘Terminal.’ This has the model of the terminal in it with the widget component attached to the screen. The player possesses this pawn to use the terminal’s controls and the widget.

The widget blueprint used by the above widget component is called ‘Interface’, Button events originate here, but I can’t seem to get them to affect the level, because they are not technically in the level, they are components of the ‘Terminal’ pawn blueprint class.

Finally, I have the level blueprint, where the functions for turning the lights on and off are. The ‘Get’ variable I created to point to the widget component is empty, because it can’t be selected in the level (because it’s contained in the Terminal BP)

I’m sure the solution is probably very simple, but I am very new to BP scripting, so any help figuring this out would be greatly appreciated!

Thanks

sorry, but - bump

Hi Ollyryder,

I would recommend you use the Event Dispatchers to handle this.

As a quick test I created an event dispatcher in the pawn.
Then in the level I can call it, or vice versa.

The trick may be in locating your pawn object reference from the level blueprint.
You can either use the editor and place a fixed reference, or do a lookup on the scene.

Here is a video that explain how blueprint communicate with other items in the scene, including event dispatchers, I would highly recommend you watch it:

Hey there, did you ever find an answer to this? I’m having the same issue.

Hi, I did manage to do this eventually.

The only way I found that worked was to use ‘Blueprint Interface’ blueprints. I made an interface called ‘ButtonPressed’ or something, Then I had to go into the class settings of the widget bp and the target blueprint and add the interface to the blueprint (it’s under class settings → interfaces, then click ‘add’ and choose from a list). Once I had done that, I created an interface message node coming off the button click in my widget event graph. A message node basically calls out events to a target blueprint every time it is called. The only problem with this was that I couldn’t target the level blueprint directly. So I made my light its own blueprint actor class. Then all I had to do to target the light from my widget blueprint was ‘getallactors of class’, select my light blueprint from the dropdown and break that with a ‘for each loop’ node. Then you can drag off the reference from the array element node, and plug that into the message. Lastly, you just have to go to the ‘light’ blueprint, and (make sure you’ve added the interface in class settings) do ‘event on ButtonPressed’ (or whatever you called the interface) then toggle visibilty/change color etc like you would do any other event.

One final thing. If you want to pass variables between the widget bp and something else it is painful, but possible. I won’t go into it now but if you need to know how to do that just ask.

I hope that answers your question. It was a right headache to figure this all out since there is pretty much nothing out there on making interactive widgets for computer terminals and such haha! I might have to make a video tutorial or something on how to do it.