# How can I create a day/night cycle in a small world?

**URL:** <https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [March 29, 2014, 3:28pm UTC](https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941 "2014-03-29T15:28:14Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shrooblord](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shrooblord/32/88712_2.png) [@Shrooblord](https://forums.unrealengine.com/u/Shrooblord)\
**Post date:** [March 29, 2014, 3:28pm UTC](https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941/1 "2014-03-29T15:28:14Z")

</div>

Hey there,

I was trying to create an automatic day-night cycle so I set up a small world in which there’s only a boxbrush, a directional light actor and a native skysphere blueprint. I set the directional light to be used by the skysphere as the light I placed and played around with its rotation a little.  
Changing its pitch (Y-axis) fully around to 360 degrees turns it back to 0 degrees rotation, as expected. The sun followed through the sky.

However, creating the blueprint to automate the process, I ran into a problem. Here is what I created in the Level Blueprint:  
[![](https://d3kjluh73b9h9o.cloudfront.net/original/3X/2/f/2f0984456f8dd47c5beb0a68b72c3d6cf62ef2aa.jpeg) ](http://tinypic.com/images/goodbye.jpg)

The thing is that the range of the pitch here doesn’t want to exceed +90 or -90. Lower than -90 will turn the pitch into 0 + the amount below -90. Higher than 90 will trip the pitch up and turn it instantly back to 90 less than half a second later.

Using higher values for the ‘add 10 degrees to the pitch’ integer box on the left will make the pitch jerk further than 90 more and more, but will still make it revert to 90 instantly.

Could you help me with this problem? I do not understand why there is only half of a circle available for the full rotation, since I can manually adjust the light in the direction I want it to within the editor - the problem is the blueprint. Maybe I need to use another rotation method?

Thank you for your time,  
Shrooblord

---

<div class="post-metadata">

**Author:** ![DizzyWes](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DizzyWes](https://forums.unrealengine.com/u/DizzyWes)\
**Post date:** [March 29, 2014, 4:51pm UTC](https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941/2 "2014-03-29T16:51:18Z")

</div>

Howdy!

There are a couple posts about this here on AnswerHUB as well as on the forums and I’ve round up a couple here.

Do any of these help point you in the right direction?

> **[Help please! Day/Night Cycle](https://forums.unrealengine.com/questions/18430/help-please-daynight-cycle.html)**
>
> Hey, i have been trying to figure this out however i am struggling. So i started with a timeline on the level blueprint aswell as a moveable directional light, and added a float track, and changed some of the numbers. Then tried lots of different...

> **[Get Sun to Follow Directional Light During Day/Night Cycle.](https://forums.unrealengine.com/questions/19209/get-sun-to-follow-directional-light-during-daynigh.html)**
>
> Ok, so i have tried to figure this out a bit more and think i have something... the directional light cycles and you can see it with lighting changes... however the actual sun on the sky sphere doesnt move. When i hover over the 'Directional Light...

As well as a forum post which has helped a few people:

> **[Working Basic Day/Night Cycle w/ Updating sun](https://forums.unrealengine.com/showthread.php?1237-Working-Basic-Day-Night-Cycle-w-Updating-sun&highlight=night%2Bcycle)**
>
> Hey folks, after a bit playing in the BP system I was able to create a basic day/night cycle. It even updates the sun’s position in the BP\_Sky\_Sphere, so you’ll still get the nice color changes around the horizon. You just have to attach your...

-W

---

<div class="post-metadata">

**Author:** ![Shrooblord](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shrooblord/32/88712_2.png) [@Shrooblord](https://forums.unrealengine.com/u/Shrooblord)\
**Post date:** [March 29, 2014, 6:14pm UTC](https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941/3 "2014-03-29T18:14:09Z")

</div>

Thank you - I’m seeing how to set this up now.

Would you happen to know why my pitch was constraint so strangely between these two values giving me a range of 180 degrees only? Why can I not animate in the full 360 degrees of motion from within a Blueprint?

---

<div class="post-metadata">

**Author:** ![hyawatha15](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@hyawatha15](https://forums.unrealengine.com/u/hyawatha15)\
**Post date:** [April 14, 2014, 3:25am UTC](https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941/4 "2014-04-14T03:25:39Z")

</div>

Has there been any progress making the pitch rotation a full 360 degrees?

---

<div class="post-metadata">

**Author:** ![Shrooblord](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shrooblord/32/88712_2.png) [@Shrooblord](https://forums.unrealengine.com/u/Shrooblord)\
**Post date:** [April 14, 2014, 1:52pm UTC](https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941/5 "2014-04-14T13:52:08Z")

</div>

No, and I’m still not certain why not. With the links provided, I was able to create the day-night cycle fine, but not using the method I was originally planning to use. I don’t know why pitch is constrained like that exclusively in the Blueprint editor; the people from Epic didn’t reply further - maybe it’s a bug.

---

<div class="post-metadata">

**Author:** ![hyawatha15](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@hyawatha15](https://forums.unrealengine.com/u/hyawatha15)\
**Post date:** [April 14, 2014, 3:21pm UTC](https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941/6 "2014-04-14T15:21:43Z")

</div>

Thanks for the update.

---

<div class="post-metadata">

**Author:** ![Steve\_Allison](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Steve\_Allison](https://forums.unrealengine.com/u/Steve_Allison)\
**Post date:** [May 4, 2014, 8:27pm UTC](https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941/7 "2014-05-04T20:27:43Z")

</div>

Hello everyone,

We have been investigating some scenarios in which rotations aren’t working as expected with blueprints, but don’t have an ETA for a fix, unfortunately.

One blueprint setup we have been able to use to create a day/night cycle is using a Timeline that modifies your directional light’s rotation with a Set Actor Rotation node. You can setup a float in your timeline that goes from 0 to 360 (or 0 to -360, depending on which axis you’re rotating around) and control how quickly it does that rotation within the timeline itself. If you would like an example of what that would look like in a blueprint, let me know and I’ll provide a screenshot.

---

<div class="post-metadata">

**Author:** ![Shrooblord](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shrooblord/32/88712_2.png) [@Shrooblord](https://forums.unrealengine.com/u/Shrooblord)\
**Post date:** [May 5, 2014, 5:37am UTC](https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941/8 "2014-05-05T05:37:23Z")

</div>

Thanks, Steve. It’s good to know that what we were experiencing wasn’t just us being idiots but was indeed a bug. 😉  
Thanks for looking into the matter.

---

<div class="post-metadata">

**Author:** ![HoOz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HoOz](https://forums.unrealengine.com/u/HoOz)\
**Post date:** [May 5, 2014, 5:44am UTC](https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941/9 "2014-05-05T05:44:51Z")

</div>

I have the same problem, I want to animate around the Pitch axis but it’s stuck at 90 degrees

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2793493e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2793493e1](https://forums.unrealengine.com/u/anonymous_user_2793493e1)\
**Post date:** [May 5, 2014, 3:41pm UTC](https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941/10 "2014-05-05T15:41:56Z")

</div>

For me Solved that Way:

Store a variable With 0-360 values and use it.  
Just remember to referer to correct TARGET in both methods.

**C++ Version**

```
void AWeather::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);
 
    SunAngle = SunAngle + (DeltaTime * BaseSpeed); // Base Speed is the velocity
 
    FRotator Rotator = FRotator::ZeroRotator;
    Rotator.Add(this->SunAngle, 0, 0);
 
    Sun->SetWorldRotation(Rotator);
 
    if (this->SunAngle >= 360)
    {
        SunAngle = 0;
    }
    
}

```

**BluePrint Version**

 ![5636-blueprint.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/f/6/df6d3e9d347714cef6e39783aad86807f57f593a.png)

---

<div class="post-metadata">

**Author:** ![Shrooblord](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shrooblord/32/88712_2.png) [@Shrooblord](https://forums.unrealengine.com/u/Shrooblord)\
**Post date:** [May 7, 2014, 11:50am UTC](https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941/11 "2014-05-07T11:50:46Z")

</div>

See above post made by Steve Allison - they’re working on the issue currently.

---

<div class="post-metadata">

**Author:** ![Shrooblord](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shrooblord/32/88712_2.png) [@Shrooblord](https://forums.unrealengine.com/u/Shrooblord)\
**Post date:** [May 7, 2014, 11:51am UTC](https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941/12 "2014-05-07T11:51:27Z")

</div>

Alright, just wanted to inform you: Steve Allison posted on this topic to say they are currently working to resolve the issue.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_cacd3de0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cacd3de0](https://forums.unrealengine.com/u/anonymous_user_cacd3de0)\
**Post date:** [January 13, 2016, 6:48am UTC](https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941/13 "2016-01-13T06:48:13Z")

</div>

Still broken in 4.10.2

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_ad4a3c1e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_ad4a3c1e](https://forums.unrealengine.com/u/anonymous_user_ad4a3c1e)\
**Post date:** [April 11, 2016, 4:26pm UTC](https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941/14 "2016-04-11T16:26:09Z")

</div>

And on 4.11.1 :S

---

<div class="post-metadata">

**Author:** ![DannRees](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DannRees](https://forums.unrealengine.com/u/DannRees)\
**Post date:** [July 13, 2016, 7:53pm UTC](https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941/15 "2016-07-13T19:53:39Z")

</div>

Any updates on this? It’s very frustrating…

---

<div class="post-metadata">

**Author:** ![Pablo1517](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Pablo1517](https://forums.unrealengine.com/u/Pablo1517)\
**Post date:** [September 11, 2017, 6:50pm UTC](https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941/16 "2017-09-11T18:50:24Z")

</div>

4.17, this will never get fixed, guys

---

<div class="post-metadata">

**Author:** ![MostHost\_LA](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mosthost_la/32/907035_2.png) [@MostHost\_LA](https://forums.unrealengine.com/u/MostHost_LA)\
**Post date:** [March 29, 2019, 8:15am UTC](https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941/17 "2019-03-29T08:15:27Z")

</div>

Still “broken” in 4.21 as well.  
It acts pretty randomly with sun rotation - following this tutorial

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

Set the sun speed to 1, it gets stuck at 90.

Implementing the Sun Angle option mentioned above is actually slightly better in terms of figuring things out though, so while this is a bug, the work-around is actually beneficial to advanced coding/scripting…

including a quick snapshot of how this changes with that.

 ![272707-b24989f4b401b1da8bb45fe35c40cf5e.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/1/9/d19ff6d7d6e3aaf98b746d53d86c21682114b2c6.png)

---

<div class="post-metadata">

**Author:** ![Slashin8r](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Slashin8r](https://forums.unrealengine.com/u/Slashin8r)\
**Post date:** [November 20, 2020, 5:09am UTC](https://forums.unrealengine.com/t/how-can-i-create-a-day-night-cycle-in-a-small-world/278941/18 "2020-11-20T05:09:51Z")

</div>

4.24, 4.25 and 4.26 this issue still exists.

HOWEVER, I have a really easy permanent fix for this. The solution: rotate the sun on a very slight angle that no one would ever notice. Set the starting rotation of the directional light tied to your sky sphere to (1.0, 88.0, 1.0) or similar numbers. This will force the sun to rotate on a slight angle and it will never be able to hit 90 or -90 in pitch.

 ![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/c/4/5c47fa3fecb2fd2d7a090de7eaada5928bcbda85.png)
