Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Variables from UMG Widgets?

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.


Product Version: UE 4.20
more ▼

asked Oct 03 '18 at 09:50 AM in Blueprint Scripting

avatar image

177 33 46 53

avatar image Everynone Oct 03 '18 at 10:01 AM
  • Which blueprint creates the widget?

  • Did you set a reference when you created the widget?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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)):

alt text

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) :

alt text

And finally the spin box itself

alt text

Easy right?

more ▼

answered Oct 03 '18 at 11:38 AM

avatar image

596 28 24 52

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question