Download

[TUTORIAL] Quick Time-of-Day Setup

UPDATE: The pre-made blueprint is available for download! Get it here: https://apps.gregbrisebois.com/downl…eOfDay_1.4.zip

  • Extract archive;
  • Copy the “Content” folder into your project folder (it should merge with the content folder already there);
  • When it asks if you want to merge folders, say yes;
  • Launch UnrealEd, and load the project you copied that folder to;
  • Go to ‘File > Open Level’ and choose “TimeOfDayTemplate.umap” (it should be located under \YourProject\Content\Maps);
  • Hit simulate, and watch the sun move!

Experiment with the properties in the blueprint. I’ve written comments for all of them (I think), so it shouldn’t be too hard to figure it out. Quick tip: If you want to change the speed of time, “Time Speed” is what you’re looking for.

For more details about this blueprint, go here: https://gregbrisebois.com/index.php/…aynight-cycle/

If it isn’t working, please make sure that you followed all of the steps above correctly. They are all necessary!

Finally, please give feedback! Was it useful? Not useful? Too complicated? Broken? Let me know below!

[EDIT Updated to v1.2]

Original Post:

Hey all,

I’ve created a quick tutorial on how to set up a dynamic day-night cycle on the wiki: https://wiki.unrealengine.com/Tutorial:_Time_of_Day

I noticed that there wasn’t much info on this, so after figuring it out I decided to share it with you all.

Hope this helps some people! And feedback is welcome :slight_smile:

EDIT: Updated the tutorial to include a section on environment customization events. Now you can change things based on the level being day or night!

One question. How did you get “Light Source” as the target for Add Actor Local Rotation?

In the 3D viewport, select your sun lamp, then right-click in the level blueprint editor and choose “Add reference to light source.”

This should work for you :slight_smile:

Thanks gregdumb, this is great. Nice and simple!

Thanks Tesla! :smiley:

Ha, so simple, no wonder I didn’t think of it. This is really cool now that I have it working. Now I’m trying to think about how I can cause events to trigger based on it being “night time”.

I would go about it by, in the blueprint, check your sun’s rotation and see if it is in the “night” range (aka below the horizon). Then cause events to happen if it is. If you check the skydome’s blueprint (select it and click “Edit BP_Sky_Sphere” in the details panel) they have the setup for this, which they used to blend in the stars.

EDIT: I’ll update the tutorial to include something like this when I have the time :slight_smile:

Very good, congratulations, I really liked it.
It was easy to understand and quick to implement.

Thanks! That’s good to hear, means I did my job right :slight_smile:

Hi i have this working but I am looking for a way to get night to look correctly is this in engine or in the editor itself? I am also getting light from under terrain that i believe i can fix via BP but i need a better night sky but i can not find the sky settings for night anywhere.

You can make changes to the sky in the skydome blueprint (just select it and, in the details panel, click “Edit BP_Sky_Sphere”). The underground lighting could probably be fixed by turning off the sun when it goes below the horizon, I’m working to update the tutorial in relation to demonstrate how to set up something like this :slight_smile:

Holy **** did not think that was a BP … now i said it it starts with bp… But yes i turn on and off the Sun brightness at 0.1 adn that works i just need to change the night settings now thanks.

Okay, to see where the sun is, just check your light’s “Pitch” rotation value. If that’s positive, it means it’s nighttime. Here’s the blueprint setup I used:

(Just look at the bottom section, starting with “Get Actor Rotation.”) You can then make decisions based on the “Night” boolean. The “Night Threshold” float determines how many degrees the sun must be below the horizon for it to count as night.

Alright, I’ve added the new section to the tutorial. This should fix the “sun coming through the ground” problem, and also give you a way to customize the environment to day or night. :slight_smile:

you could use sun height to tell day and night at night the height is <0 To get the sky to actually change to night i had to modify the lerp to make my own night lery color and transition to that but now if i use a sky light my terrain gets bright at night. I’m going to see if yours does the same… are u using a terrain?

Also I think im going to add skylight behavior to the Sky sphere. its still weird that when night starts the skylight seems to illuminate like mad

I don’t think height<0 will work, the sun in UE4 goes by rotation, not height. No, I’m not using a terrain in the tutorial, but I have used it before and it should work.

I see now I dont know what changed but the sun height does not even get to the top of or or -1 now. but i have it working. I’m adding the ability to control day cycle based on a total Seconds for cycle also I’m making a get Time function that works for 24 or 12 hour days., I’ve also integrated your change into the BP it self. Would you want me to share once I’m done? I’m brain storming adding Day night cycle and stor cycle to be able to blend to a weather environment state machine at random of on call.

Wow, nice work man! Sounds like you’ve made progress :slight_smile: Feel free to add it to the wiki page if you want of course!

Awesome job man! I really liked the way you added in the parts to trigger events for at day/night. The much simpler version I created ( Working Basic Day/Night Cycle w/ Updating sun - Blueprint Visual Scripting - Unreal Engine Forums ) didnt have that, but I’ll likely be adding it.