# Directional light rotation issues?

I am trying to get a 24 hour day and night cycle working. Something that I can change the time on demand to exactly the time of day I want it to be, just like in skyrim and such games.

My big issues is that I have no idea how to handle the rotation of the light… it does a weird 0 - 90 and 0 - -90 type of thing instead of a 0-360. If it was 0-360 I could just clamp the values I would assume within range into 0-24. Or do I need to do the 180 rotation style? Either way I am absolutely confused and keep getting stuck and getting extremely confused with all this…

Also needs to loop so you can keep going from day to night back into day… Having a smooth number like this would allow me to also adjust light intensities more accurately as it changes as well instead of just timelines that change it at specific moments all at once for the entirety of day or night.

Anyone please I am losing it, wasting so much time trying to find anything that helps do this properly.

You need to adjust the pitch of the light, by adding rotation offset ( very exagerated here )

Thank you, but not exactly what I was looking for, that is the most basic part in the tutorials I have found so far.

I get that, but what I am trying to achieve is having a value I can properly use to set time and stuff like that instead of just having it add rotation to change time gradually. So I could just input 1pm or 13 which is 13 hour of a 24 hour day, and it will go to that specific rotation and time immediately.

The problem is that I cannot figure out how to transfer the rotation into the 24 hour format or 360 rotation format that I clamp into a 24 hour format or anything like that. I am so confused by how to work with how it is rotating number wise… All other objects I can just rotate 0-360, this goes 0-90 then 90-0 then 0- -90 and then -90 - 0… or something like that. Idk how to even attempt approaching that… At least that is what it is printing when I get the actor rotation and using a print node…

I’d recommend googling around. This topic has come up on here hundreds of times.

Easiest way is to just get an asset ( like Ultra Dynamic Sky ).

1 Like

Trying to look it up and not getting anything… Just spammed multiple copies of each post because the search doesn’t just look for the title, but all separate posts in that post too… No good way to transfer between the values ?

May use that though anyways I suppose. Didn’t realize I even had it.

Do it in google, that will take you to the right posts.

There’s no clean way. Unless you want to use quaternions.

I stand corrected, see below.

Hey @Gore23!

Another solution you can try is Unreal’s built in Sun position calculator. It has built in functions for time of day, and even has a great tutorial put out by the Unreal Engine team:

I hope this helps point you in the right direction!

2 Likes

There is a plugin called sun position calculator. Enable it (in plugins) and drop it in the level (it is called SunSky). Could be helpful for sun positioning.

Dam_n it Quetzalcodename. Not wasting a good reply just because you were faster.

1 Like

Hey @Gore23!

Checking in! Did the above solution provide the solution you need to solve your problem?

@Quetzalcodename It might, I took the suggestion of just using ultra dynamic sky instead of making my own. Did not realize I had it, and making my own was turning way too troublesome… Other solutions look promising if one wants to continue the path of making their own though.