x

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"

How to bind a Slider UMG to a variable from another Blueprint?

Hi everyone,

I'm currently developing an application for architectural visualization and I'm struggling so hard with a question about programming my UMG on screen.

The thing is: I downloaded a day/night cycle in the market place and I set it up. In game it is changable with a variable which controls the rotation of the sun and the moon. I created a Slider in order to control that variable with the mouse cursor. So I just want to know how to bind this variable to the Slider in order to make the user be able to control the cycle ingame.

I have two Blueprints: One for the UMG were the slider is placed, and another with all the day/night cycle programming.

Now I'll upload some screenshots of the most important parts (I think they are) in order to solve this.

alt text

alt text

As you can see here, I set up a OnValueChanged function for the Slider, and with this I get to change the value of the slider with the mouse, but not the value of the variable I need.

alt text

alt text

Here you see I created a function where I scaled the range of the slider between 0 to 2400 (the cycle range controlled by the variable I need to dynamically change also goes from 0 to 2400).

alt text

[5]: /storage/temp/249809-setslidervalue.png

And finally, here's the variable I need to change. This is the Blueprint from the Day/Night cycle I downloaded at the Marketplace. I think it's the most relevant part of this blueprint but I don't know if it's even needed to just know how to change with the slider a variable from another BP... right?

Thank you so much in advance for any help, everyone!!

Product Version: UE 4.18
Tags:
more ▼

asked Aug 08 '18 at 08:07 AM in Blueprint Scripting

avatar image

kratos500
26 5 7 8

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

1 answer: sort voted first

I have two Blueprints: One for the UMG were the slider is placed, and another with all the day/night cycle programming.

Do you need to have this slider in a separate actor? Why not create the widget in the Day/Night cycle actor? Just asking, you may have a very good reason to keep them apart.


Generally speaking, it's a matter of obtaining a reference. You need a widget to gain access to the Day/Night actor and make the widget's slider set Day/Night actor's variable.

  • where do you create the widget? (in a separate actor, framework class, level blueprint)

  • where do you create Day/Night cycle actor? (manually placed in the level or you used SpawnActorsFromClass node?)

more ▼

answered Aug 08 '18 at 02:10 PM

avatar image

Everynone
15.3k 77 26 64

avatar image kratos500 Aug 09 '18 at 10:04 AM

Hi Everynone! Thank you for your reply!!

I just got to the office so I couldn't answer earlier, apologies!.

I need the slider in a separated actor from the night/cycle, because I already programmed the UMG of the app separately with other simple functionalities. So I created the slider inside a Widget blueprint I made for a Minimap in this project, so I thought the best way could be to just include the Slider inside the same canvas where I have the Minimap. The Slider is working fine and it gets the values I need (in a range from 0 to 2400) but I just need to ''Bind''(?) these values to the day cycle variable (it's name is Time Of Day, you can check it out in the last screenshot), that it has the same value range, from 0 to 2400. This variable is created inside another whole Blueprint Actor just focused on the D-N Cycle programming etc. So whenever I change the value of the Slider, I need to change the Time Of Day value as well, in order to make them have the same value all the time (that's why I tried to make it work through the Event Tick in the Day Cycle Blueprint, by getting a reference to the Widget Blueprint). I kept trying this stuff today, and now I have it like this: alt text alt text Okay, both images are form the DNCycle BP. The first image shows how I now have the set up trying to get the Slider Value with a reference to the Widget. I pluged it to a IsValid node because I wanted to check out if it's getting it or not. You can see is not valid, so, in the second image, I tried to Get all Actors from widget but still is not working, so I'm not sure if I'm going in the right direction on this...

Just in case it's necessary, I notify the Slider Widget blueprint still being the same as yesterday, I changed nothing! So you can check it out in my previous screenshots as well.

Thank you sooo much again Everynone, I appreciate your help!!

avatar image kratos500 Aug 09 '18 at 10:05 AM

Ah! And I create the Day/Night cycle actor by placing it manually into the level!

avatar image Everynone Aug 09 '18 at 10:19 AM

I need the slider in a separated actor from the night/cycle, because I already programmed the UMG of the app separately with other simple functionalities.

Makes perfect sense.

Ah! And I create the Day/Night cycle actor by placing it manually into the level!

Ok, that's the important part. You can use GetAllActorsFromClass to obtain the reference providing you will never have more than one FloorPlan. From the Found Widgets pin Get 0 element instead. This will work but it's not a good solution in the long run.


So I created the slider inside a Widget blueprint I made for a Minimap in this project, so I thought the best way could be to just include the Slider inside the same canvas where I have the Minimap.

This is the second piece of the puzzle - where do you create the Minimap? We'll need this info to connect the widget and the day cycle actor together. Once we get access to the Minimap, we get access to the slider as well.

avatar image kratos500 Aug 09 '18 at 10:42 AM

It worked!! I just used Get all Widgets Of Class and passed them through a ForEachLoop node (as you said by getting reference to the Minimap-Slider Widget is enough!), and now the reference is valid and it worked!! So simple! I can now control the cycle variable nicely!!

alt text

alt text

alt text

Once again Everynone THANK YOU! you were so nice and helpful mate, I'm checking this question as resolved!

Cheers!! :)

avatar image Everynone Aug 09 '18 at 10:46 AM

Glad to hear you got it to work but you can use Get node instead of ForLoop. A bit simpler.

Also, this is a ham-fisted approach that will get you in trouble eventually. ;) Again, if you only plan to have 1 slider, you should be fine...

Good luck with the rest!

avatar image kratos500 Aug 09 '18 at 11:29 AM

I changed to the Get node to follow your recommendation. I'll have it in mind!

About the case if I wanna try getting more than one slider on screen, what should I have in mind or what should I change to get it working? No plan to do it yet but in the near future probably I would need it.

Thank you very much again Everynone!

avatar image Everynone Aug 09 '18 at 11:35 AM

Where do you create the Minimap? We'll need this info to connect the widget and the day cycle actor together. Once we get access to the Minimap, we get access to the slider as well.

Once you know which blueprint creates the minimap you can ask the DayNightCycle to fetch the blueprint, which can fetch the minimap widget, which can fetch the slider. :)

I know how it sounds. Overly complicated but it's done only once.


You can use what you've got for now, once you need something more advanced, feel free to post a comment here or start a new thread.

avatar image kratos500 Aug 09 '18 at 11:53 AM

It sounds overly complicated but super interesting to know! And doing it would make loads of work easier right? I wanna know!

I think I get it! Okay, I created the Minimap (so you mean adding the Widget to the viewport?) in the FPCharacter, in the Event Begin Play node by Creating the Widget and Adding it to the Viewport.

Again thank you so much really!!

avatar image Everynone Aug 09 '18 at 12:16 PM

First of all, you need to store the reference to the widget in the actor that created the widget:

alt text

From now on, if you access the character blueprint, you'll have a ready reference to the widget.

In your DayNightActor do something like this on BeginPlay:

alt text

This will take the minimap reference from the character and assign it to a variable in the DayNightActor. So you do not have to cast every time you want to use the widget.

If your widgets are more complicated (widget creates another widget inside), you will need to ensure that every time a new widget is created, you store the reference as in pic 1.

daynight.png (119.1 kB)
tpp.png (89.1 kB)
avatar image kratos500 Aug 09 '18 at 12:45 PM

This is simple after all!! and so well explained! I just changed it to make it like this. alt text

So I just set it up like this as you did. Super easy to understand! I think this was some stuff I didn'y really know how to work with but it's quite simple! (I used a sequence because I'm not sure if it's okay to do it together with the other stuff)

You Everynone rock !! Thank you once again!!

avatar image Everynone Aug 09 '18 at 12:48 PM

Yup. Looks good. Now you can get rid of the GetAllActorsOfClass, too ;P

If you ever need to create more sliders, it's a matter of creating more variables to store their references.

(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