- Home /
Infinite Range, Smooth, Day-Night Cycle
Could somebody please tell me how to implement a day-night cycle with smooth transition that has no limitations placed upon its range.
Firstly, I would like the sun and moon to move smoothly across the sky.
Secondly, my terrain is infinite. Therefore, I would be grateful for a sky that is infinitely far away.
However, if you have a solution but it proves me wrong about either of my conclusions, please tell me about it.
wait, did you come here asking for someone to code this out for you ?....
What you should do is actually work your way toward a solution, then come here asking if you're on the right track...
The whole "I request" thing kind of comes off as "agressive" - to me at least.
Thank you for telling me so, I have amended my question.
I would merely like to be pointed in the right direction, and I have explored possibilities, but they didn't deal with radius expansion or infinite distance.
I find that finishing the work myself aids my understanding, and thus I can answer other questions on the same general field in a more skilled fashion.
If you wish to appear helpful or friendly upon the first impression, please use the ter$$anonymous$$ology "I recommend" ins$$anonymous$$d of "You should" when commenting.
Answer by betaFlux · Sep 07, 2014 at 03:59 PM
Hello Justice, my advice: Follow the BurgZergArcade tutorial series about Day Night Cycle beginning with this video. As for the infinite sky distance, may be once you have finished your Day Night Cycle, you are skilled enough to implement this feature by yourself, or may be it would be enough to let all relevant sky objects move along with/rotate around the player.
Thank you! I will try this as well as the above answer. I particularly enjoy following YouTube tutorials, and this series looks promising.
Thanks for calling me 'Justice', I find it very enjoyable and it makes you seem friendly and happily helpful.
Well, that was kind of you too! :) I also enjoy following yt tutorials especially the BurgZergArcade episodes. Petey is such cool guy, it is fun listening to him. I also followed these tutorials and created a Day Night Cycle for my game and I still use it, since 2 years. It's simplicity itself and thus easy to edit, even for a beginner like me.
All right, it's all done! $$anonymous$$y day-night cycle is coded fully and everything that should be related to the time is so. This was achieved through all of your answers (thank you very much), other questions and answers on this site, and a variety of YouTube tutorials, from betaFlux and otherwise.
@betaFlux I accepted your answer in particular because it gave access to lots of advice, and I could learn the coding myself via following the tutorial, as I have with my old favourite.
Answer by jokim · Sep 03, 2014 at 04:29 PM
Now, If i was to actually take a shot at an "answer" I'd say :
Have you thought about making the sky a set distance from the player (or the camera).
What i'm seeing is some sort of a sphere (huge, indeed) that has the sky on it (a sky dome), and has a moon and sun rotating around it. That sphere could be attached to the camera or the player. that way, it gives the illusion of "infinite" as you're never getting any closer to it.
That's a very good idea, I'll try it and tell you if it works or does not do so.
Answer by TD10074405 · Sep 04, 2014 at 05:47 PM
My own personal method is to use a Sphere as above, delete the mesh renderer (or just disable) attach a directional light source at a point (Preferable at 92 Degrees so its beyond your horizon / below your terrain) this will be your "Sun"
you will then need to declare a simple sec/min/hour/day float to say that 1 day = 24hr, 1 hr = 60 min, 1 min = 60 secs
basically then rotate the sphere by adding setting your objects transform rotation equal to current time (A variable, float) + Time.deltaTime, Which should rotate per second.
I can write a longer response later on if needs be.
Thank you for the extra information, I will retry the above method with it.
@TD10074405 I have finished with your method, and it was brilliant for the sun and moon. Thank you for it!
@jokim The same applies to you.
I have never had more than one answer to accept before, and I want to accept everybody's. betaFlux is definitely going to be accepted, but I want to accept yours, TD10074405, because of your idea and your detail. I up-voted jokim because of his idea.
Your answer
![](https://koobas.hobune.stream/wayback/20220613162225im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to generate infinite cube world / minecraft terrain with perlin noise? 1 Answer
Animation speed control - no smooth animation on slow down 3 Answers
2d camera help! 0 Answers
Turn page, smooth rotate 1 Answer
Smooth rotation problem 1 Answer