Download

Using a widget button to control other blueprints

So I’ve been trying to get this to work for legitimately like 10 hours now and it’s incredibly frustrating.

My end goal is to have UI buttons I can use to play animations on a skeletal mesh but for the time being I’m starting with something more simple, using a button to change the color of a light.

I just want to preface this by saying I’m very new to unreal engine, and game engines in general. I also hate using nodes. I much prefer straight code but for some reason unreal engine thinks I don’t have visual studio installed so I’m stuck with nodes (but that’s a problem for another post).

So here’s the goal:

Here’s what I’m trying to do currently:

And here’s how I’m trying to do it:

But I can’t use the variable there because it needs an object reference, and I can’t create an object reference to the widget blueprint.

There’s a myriad of ways to do it, all boils down to that the event needs to inform the goal, but not necessarily directly.
The simplest way might be to, in the widget after setting the boolean:
“get all actors of class”, select point light, drag off the array and do a loop. Now you can set the light color directly, or you can call a function on the light that does it.

The “get all actors of class” method I would only use for testing.

Another way might be to have an actor to act as a mediator. Something like Widget->ControlActor->Light.
The control actor of course needs to either get these objects references or be given them.
Something you could do is to add an array to the ControlActor of type Point Light, then in the array properties check “instance editable”. Now you can drag the ControlActor into your scene and in its details panel, see the array. Add an element and use the “pick actor from scene” tool to select the light.
Then, pass the ControlActor a reference to the widget when it is created and:

  • bind events, but maybe that might be a bit complicated if you’re new.
  • Have the widget call functions on the ControlActor to pass on to whatever needs to be informed.