I’m trying to access a widget variable from the level blueprint but i cant figure out the best way to do it.
I have a spin box on the GUI set to 0 - 1. When the player changes it i want it to update the red value in the lights of the scene. So, “on value changed” It will update a float variable in the UMG widget, but i want that to be updated in the level blueprint to affect the red value.
I just cant figure out how to get the information send from the variable in the UMG to affect the parameters in the level blueprint.
I think you’re a little too set on doing it a specific way.
Level BPs are not meant to be accessed externally. There are ways around this such as event dispatchers and others with C++ (via ALevelScriptActor). But when you start fudging UE4 to do things that it didn’t intend you start running into issues down the line.
The good news is that once you’re familiar, it’s easy to see where the pieces of the puzzle go and there’s nothing that’s not possible.
For this issue I would have a GameStateBase blueprint with an array of light components and a SetLights custom event, and it would look something like this (terrible example of how to modify the colour, at 0 it would be green/blue and 1 it would be white, naturally you’ll want to modify other channels too, perhaps with (1-RedValue)):
Then, each light would be in it’s own blueprint that registers the light with the GameStateBase BP on begin play (this is the “correct” way, alternatively GameStateBase could do GetAllActorsOfClass → ForEachLoop → Cast to Light → GetLightComponent → Add to the array, however this scales poorly on larger projects and is bad practice; proper chain of references is always ideal) :