Download

Day and night cycle

i made a day and night cycle but in my opinion i think the night is too short. anyone know how to fix this?

Try changing your Blueprint to this:

You’ll need to create the float variable “Night Speed.” It isn’t truly the speed relative to the Day Speed, but I recommend you make the Night Speed 5% the size of the Day Speed.

To code works by detecting the “Nightness”, then adjusting the speed based on that. Also, you’ll really need to make the Night Speed really low if the sun doesn’t get very high in the sky.

Hope this helps!

1 Like

there’s a node called add rotating movement component, use that instead because you dont need to use tick, it hooks up to event begin.

add one of those for each dir light with different speeds of course.
then you could control them both with a variable as a multiplier.

yeah it works thanks, but ive heard that i should use a sky atmosphere instead of a bp skysphere. know anything about that?

In this case, using Tick is pretty acceptable, given that the rotational rate needs to be changing constantly. It’s not like it give a performance boost either, because the RotatingMovementComponent uses Tick underneath.

you can use whatever you like and put the logic wherever you want. you can even make your own sky actor that in time you could add lots of cool features not just day-night cycle

yeah thanks, now ive been trying to setup a sky atmossphere with a day n night cycle and with a moon and a sun. tried to follow this tut UE 4.25 - Sun, Moon, & Volumetric Clouds - YouTube but when my moon comes up it becomes day again.

When the moon comes up you will need to set new parameters for your directional lights, your fog, and your skylight. I use a timeline to drive the day/night cycle and have a parameter collection to store my day/night values to transition to.

for a noob this is gibberish :joy:. but so for example when the moon comes up i have to change it to another material/parameter and use a timeline to make the transition more smooth?

My apologies if that was too vague. When transitioning from day to night and back to day there are many variables within the components that I listed above which effect the colour/lighting.

I recommend you first start by going through all of the settings in those above listed items to make a nice daytime look. Record all of the settings once you are happy with the daytime look. Then, do the same for a nighttime look and once you are happy with the look, record all of those settings.

Once you have a nice set of daytime settings and nighttime settings you can use a timeline to not only drive the rotation of your directional lights (sun and moon), you can add float channels to the timeline to use as an alpha to transition between those day/night variables which you previously recorded. You would of course want to store those previously recorded variables in a combination of local variables within your blueprint and parameter collections (I suggest you study those and familiarize yourself with them before diving in to the logic).

So in summary, make a daytime and a nighttime look you are happy with by adjusting all of the settings to your desire and make a note of them.

Then, convert those in to parameters within a parameter collection so that you can easily swap day to night.

Once you have those stored, make a timeline which drives the movement of your lights and set up the transition points using a float channel which will be the alpha for the lerp between the parameters.

If you are new to this I understand that’s a lot to take in but try to break it down in chunks and learn one thing at a time, experimenting along the way.

1 Like

okay so i did some experimenting and i got this atleast working. its not very nice but i can work on that. but i got this weird instant dark effect. do you know anything about that?

Your scene is missing an exponential height fog component. Is realtime capture turned on for your skylight? I don’t think it is from looking at this video (this is a 4.26+ feature).

Here’s an example of some of the settings I have for the day and night positions that I have saved, this particular project doesn’t have a day/night cycle, just a toggle, but if it did I could just transition these values.

Here’s what the scene looks like with those settings during the day

and during the night

Yeah i added exponential height fog and it looks better now. and the light problem i had is gone. and if i want to add stars do you know anything about that? and thanks for taking ur time i really appreciate it

1 Like

i’m glad you got that first problem sorted out!

As far as stars are concerned there are many ways to go about it but it is one of the large tasks on my list which I have yet to tackle and couldn’t confidently offer any solid advice as I have some ideas that I need to test out before I can prove that they work well.

Having said that, it is pretty common practice to use things like noise with an additional panning layer to mask it out in order to give it a little sparkle, you could combine that with a stylized Texture, a good program for that is free and open source, I believe it is called spacescape. This would be wrapped up in to a material that is used on a skybox or a sky sphere. you could even use this on your daytime sky material and have it lerp using a parameter collection driven by your timeline on your sky blueprint.

1 Like