Day/Night cycle turns black at night and how to Serialize it rightly?
Hey guys , i followed a simple Tutorial for an day/night cycle.
Firstly, the Skybox turns completely black (it's kinda weird) but i just want it to be like dark blue or something?
Secondly, I am using unet and I just noticed that the time is beginning from 0 to who ever is joining the room... like it's 17.00 pm for me but he joined right now and it's 00.00 for him/her..
Thanks in advance :)
My script: using System.Collections; using System; using UnityEngine; using UnityEngine.UI; using UnityEngine.Networking;
public class DayNightCycle : MonoBehaviour {
//[SerializeField]
public float time;
public TimeSpan currenttime;
public Transform SunTransform;
public Light Sun;
public Text timetext;
public int days;
public float intensity;
public int speed;
// Update is called once per frame
void Update ()
{
ChangeTime();
}
public void ChangeTime()
{
time += Time.deltaTime * speed;
if(time > 86400) //86400 = 00:00
{
days += 1;
time = 0;
}
currenttime = TimeSpan.FromSeconds (time);
string[] temptime = currenttime.ToString () .Split (":"[0]);
timetext.text = temptime[0] + ":" + temptime[1];
SunTransform.rotation = Quaternion.Euler (new Vector3((time-21600)/86400*360,0,0));
if (time < 43200)
intensity = 1 - (43200 - time) / 43200;
else //Even if i disable this lines there's no changing in the darkness of the game...
intensity = 1 - ((43200 - time) / 43200 *-1);
Sun.intensity = intensity;
}
}
Your answer
Follow this Question
Related Questions
UNET: Network.isServer/isClient = False; PeerType = Disconnected but accepting connections? 0 Answers
ClientRpc not functioning 0 Answers
How to Disconnect a client from the server properly using unity Netcode for GameObjects ? 0 Answers
Can anyone tell me how to fix this problem???? 1 Answer
What's wrong with my script ? 0 Answers