Download

Toggle Lights with UMG

Hi guys,
I’ve been trying to turn on/off some lights with a UMG button. I’ve read a bunch of stuff, but since I’m new to Unreal I’m not getting any results.
The workflow I’m trying is:

1- Create a blueprint called Wall Sconce with a Spot Light component, and a Event Graph with a simple custom event linked to a Toggle Visibility;

349bcbcf0e3e77caf648678e4671e0bd4777e4fe.jpeg

2- Create a UMG blueprint that, On Clicked, will select all instances of the Wall Sconce and run the simple event created at Wall Sconce.

123cf3b92e4c396bec6df61c49891a92792d4d39.jpeg

What am I missing?
Thanks a lot, cheers!

It seems like it should work, maybe visibility isn’t the problem. Maybe start by making the lights to switch on/off automatically every 1 second to see if it works.

You should set light intensity rather than visibility. Toggling visibility will dictate whether the light objects are visible in the world, not whether they will be switched on/off. Set light intensity to 0 for switching off, and then to <insert preferred value> when you need them switched on.

Hi guys, I got it solved, thank you for your input!
Since some noobies like me may be looking for a solution as well, I’ll explain what was the issue.
To make a widget interact with a light we need a total of 3 blueprints:

  • One actor blueprint with the light itself, where the code will execute exactly what you desire with it, in my case an animation with the intensity:

lightBlueprint.jpg

  • One widget blueprint with it’s layout (buttons and such), where the code will call the the event from the light blueprint:

0dd3d617e3fef27d27d4f019904bd77eb818027f.jpeg

  • One actor blueprint with the widget blueprint loaded, where the code is merely for enabling the user to properly hover over the buttons:

00ab5454d8a19714cd6c9b791198dee5414be359.jpeg

The reason I was doing wrong is because I was ignoring the code from the widget blueprint.
If anyone has a better way of doing it, please do tell us!
Hope this helps.

Cheers!