connect the sun (directional light) rotation to a slider in a widget

hay guys.
First of all I’m a NOOB so please be mindful of that fact when choosing the answer difficulty.
I’m trying to connect the sun (directional light) rotation to a slider in a widget, the problem is that i cant directly reference the directional light (sun) actor inside the widget graph where the slider is.

How would i go about referencing an actor inside a widget graph/blueprint so i could move/rotate that actor?

U can make an actor (ASun) containing the light component and the widget component, where in the Tick method u can read the value from the widget component and update your light component

Which blueprint is responsible for creating the widget?

edit: I wouldn’t go the route **Fallonsnest **is suggesting. Slider can use onValueChanged, no reason to get Tick involved in this.

True, this option sounds better :wink:

there is an actor blueprint in the scene that contains the sun and also a couple more objects, this blueprint actor creates the widget

So the sun (directional light) is in the same BP that creates the widget? Or no?

yes it is in the same blueprint

Super easy then.

Create a variable of type *Directional Light Component *in the widget, make it *Instance Editable *and Expose on Spawn. When the BP creates the widget, you’ll see an additional pin on the node named like the variable in the widget. Plug your sun there.

HI any updates for how to move sun with help of slider??

**@Maikelnasr:

**

That’s pretty much all you need. Ensure the Sun is Movable.

1 Like

Thank You for the awesome solution however, I need the blueprint start the default value from my scene. The end of the slider will be night time and from the start of the slider will be daytime which is early morning. How could I achieve this result by Blueprint?

Look at the slider details - you can put any values there directly. And you can remap any value to anything else using the nodes above.

So, referencing @Everynone’s post above, you could set Out Range A to a nice value that looks like morning (by playing with the light rotation in the editor), and set Out Range B to a nice value that looks like night.

image

Now you have a slider that spits out every minute of a 24h day.