Search Unity

24 hour night cycle

Discussion in 'Getting Started' started by Faksper, Sep 17, 2019.

  1. Faksper

    Faksper

    Joined:
    Feb 8, 2019
    Posts:
    20
    Hello i am new to unity and i searched youtube for fully night time cycle couldnt find a script for it

    What if i wanna make my game in dark atmosphere instead of day/ night cycle,
    something like the movie 30 Days of Night

    Different tones of night cycle through gameplay, can s1 share a script for that ?
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    There's some assets on the Asset Store for night cycles. Generally a day/night cycle system will be much bigger than a single script, but depends on what functionality you really want.

    Just as an example, here's how my game's fairly simple day/night cycle system works:

    I have a script which is constantly rotating a directional light and deactivates it when it goes below the horizon. I'm just using that default procedural skybox, which does a good enough job positioning a sun in the sky and going from blue sky to black based on the light direction.

    I have a script which tracks the time of day and the "phase" of the day (dawn, dusk, day, night, and transition phases between each) which adjusts the color of a volumetric fog asset (distant objects are tinted blue during the day, orange at dawn, grey at night, etc) as well as some other colors such as bodies of water.

    I crated a stars system which activates at night, and places particles in a dome shape at the outer edge of the camera's max view distance, and follows the camera without rotating so the stars appear as part of the background sky.
     
    Last edited: Sep 17, 2019
  3. Faksper

    Faksper

    Joined:
    Feb 8, 2019
    Posts:
    20
    hi thanks for answer i do appreciate it . Thanks for explaining whats goin on inside script, but as i told before i wanna remove day part from the cycle

    dusk > night > dusk > night

    i am ok with a basic script if it functions correctly . I would like to hear that asset's name if there is any, all i see day / night cycle assets
     
    Last edited: Sep 18, 2019