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

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:

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

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?

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

-W

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?

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

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.

Thanks for the update.

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.

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

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

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

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

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

Still broken in 4.10.2

And on 4.11.1 :S

Any updates on this? It’s very frustrating…

4.17, this will never get fixed, guys

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

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.

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.

1 Like