wiki.sine.space | sinespace

Difference between revisions of "Day/night cycles"

From wiki.sine.space
Jump to: navigation, search
Line 13: Line 13:
 
First you will need a directional light to which to attach the script component.  A directional light was included when you created a new scene.  If one isn't in the hierarchy panel (maybe you deleted it), you'll need to add one.  Go to the menus at the top of the editor window and click Game Object - Light - Directional Light.  
 
First you will need a directional light to which to attach the script component.  A directional light was included when you created a new scene.  If one isn't in the hierarchy panel (maybe you deleted it), you'll need to add one.  Go to the menus at the top of the editor window and click Game Object - Light - Directional Light.  
  
You'll need to add the DayNight component (script) to your directional light. Oddly, you cannot add this script with the 'Add Component' button. Instead, you must click on the Project tab, and type daynightcycle into the search box.  Click on the script with the C# (DayNightCycle.cs) and drag it up into the Hierarchy window on top of the Directional Light (the Directional Light will become highlighted light blue). 
+
You'll need to add the Day Night Circle component (script) to your directional light. You can create a new empty object to attach with this component.
 
+
Then return to the Inspector tab and scroll down to see the script/component added and click on the left arrow to open it and show the settings.
+
  
 
----
 
----
Line 27: Line 25:
 
|}
 
|}
 
----
 
----
By default, the light will be particularly harsh, the cycle will be set to 1440 minutes (a full 24 hr day), will cast no shadows, and have no visible source. This is most likely not what you want, so adjust the light color (a slightly reduced-intensity white tinted slightly orange is a good start), set the day length to something much quicker (15 mins is a good place to set this while tweaking it -- after you have the rest of it configured to your preference, you can then lengthen this out to the desired timeframe).
+
By default, the light will be particularly harsh, the cycle will be set to 1440 minutes (a full 24 hr day), and start from mid night. You can modify the duration as you wish. Toggle the "Use local System Clock" on will use your local timestamp instead of using server time.
  
Next slot your directional light in the 'Sun Light' slot in the Day Night Cycle script component (click the small circle at the right of the 'Sun Light' box to bring up a window with your choices).
+
If you pick "Use Fixed", the time will be locked, you can set the time you want fix by modify the slider bar of "Fixed Time of Day", the value is from 0 to 1, corresponding the color bar of sun.
  
Toggling the 'Use local System Clock' and 'Shader send time of day' will align your day/night cycle with your real-world local time. I'm uncertain how that will play out if your day length is other than 24 hrs. Finally, if you want to see the sun in the sky, slot the 'Sun' light source type in the 'Flare' slot.
+
Next drag the "Sun light" object into the Sun Light slot, if you create the region by using quick start, then it's the object called "Sun" controls the sun light.
 +
 
 +
Toggling the 'Use local System Clock' and 'Shader send time of day' together will align your day/night cycle with your real-world local time. I'm uncertain how that will play out if your day length is other than 24 hrs. Finally, if you want to see the sun in the sky, slot the 'Sun' light source type in the 'Flare' slot.
  
 
Selecting some type of shadows and adjusting them will produce that effect.
 
Selecting some type of shadows and adjusting them will produce that effect.
 +
 +
You can add events like playing music. The events trigger is set to Dawn, Midday, Dusk, and Midnight.
 +
 +
If you have water-like things in your scene, you can attach its material to the water material slot, which can make the light affect to the water too.
  
 
There are additional qualities that one can employ to various ends; I'll leave it to the reader to explore and deploy these according to their needs. This should be a great start however, adding 'outdoor' environmental lighting to your scene.
 
There are additional qualities that one can employ to various ends; I'll leave it to the reader to explore and deploy these according to their needs. This should be a great start however, adding 'outdoor' environmental lighting to your scene.

Revision as of 10:30, 10 January 2019



Level:

  • Beginner Unity/Space

Goals:

  • Implement Day/Night cycle on a region

This wiki entry describes how to set up day and night on your space region using the Day Night Cycle Script component.

First you will need a directional light to which to attach the script component. A directional light was included when you created a new scene. If one isn't in the hierarchy panel (maybe you deleted it), you'll need to add one. Go to the menus at the top of the editor window and click Game Object - Light - Directional Light.

You'll need to add the Day Night Circle component (script) to your directional light. You can create a new empty object to attach with this component.


Adddaynightscript.png
Fig. 1: Adding the Day Night Script component to the directional light

By default, the light will be particularly harsh, the cycle will be set to 1440 minutes (a full 24 hr day), and start from mid night. You can modify the duration as you wish. Toggle the "Use local System Clock" on will use your local timestamp instead of using server time.

If you pick "Use Fixed", the time will be locked, you can set the time you want fix by modify the slider bar of "Fixed Time of Day", the value is from 0 to 1, corresponding the color bar of sun.

Next drag the "Sun light" object into the Sun Light slot, if you create the region by using quick start, then it's the object called "Sun" controls the sun light.

Toggling the 'Use local System Clock' and 'Shader send time of day' together will align your day/night cycle with your real-world local time. I'm uncertain how that will play out if your day length is other than 24 hrs. Finally, if you want to see the sun in the sky, slot the 'Sun' light source type in the 'Flare' slot.

Selecting some type of shadows and adjusting them will produce that effect.

You can add events like playing music. The events trigger is set to Dawn, Midday, Dusk, and Midnight.

If you have water-like things in your scene, you can attach its material to the water material slot, which can make the light affect to the water too.

There are additional qualities that one can employ to various ends; I'll leave it to the reader to explore and deploy these according to their needs. This should be a great start however, adding 'outdoor' environmental lighting to your scene.


Lightdetaildaynight.png
Fig. 2: Directional light details

A huge thanks and a shout out to Adam Frisby and the Sinewave team for implementing this feature, and to Adam Frisby for walking me through this such that I could get it done right (and make a wiki entry about it ;)