From 61bf7de96fa97e5f28af3161946400e2640ab945 Mon Sep 17 00:00:00 2001 From: Vladimir Koshevarov Date: Tue, 13 Dec 2022 12:46:42 +0200 Subject: [PATCH] fix sun --- Assets/Scripts/TimeManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Assets/Scripts/TimeManager.cs b/Assets/Scripts/TimeManager.cs index 366d8f80..989d8486 100644 --- a/Assets/Scripts/TimeManager.cs +++ b/Assets/Scripts/TimeManager.cs @@ -78,14 +78,14 @@ public class TimeManager : MonoBehaviour private void RotateSun() { float intensityMultiplier = 1; - float timeofDay = (float)CurrentTime.TotalSeconds / 86400; + float timeofDay = (float)(CurrentTime.TotalDays - CurrentTime.Days); _sunLight.transform.localRotation = Quaternion.Euler((timeofDay * 360f) - 90, 170, 0); - if (_currentTime > _sunriseTime && _currentTime < _sunsetTime) + if (timeofDay > _sunriseTime.TotalDays && timeofDay < _sunsetTime.TotalDays) { - if (timeofDay <= 0.25f) - intensityMultiplier = Mathf.Clamp01((timeofDay - 0.23f) * (1 / 0.02f)); - if (timeofDay >= 0.73f) - intensityMultiplier = Mathf.Clamp01(1 - (timeofDay - 0.73f) * (1 / 0.02f)); + if (timeofDay <= _sunsetTime.TotalDays) + intensityMultiplier = Mathf.Clamp01((timeofDay - ((float)_sunsetTime.TotalDays - 0.02f)) * (1 / 0.02f)); + if (timeofDay >= _sunriseTime.TotalDays) + intensityMultiplier = Mathf.Clamp01(1 - (timeofDay - ((float)_sunriseTime.TotalDays - 0.02f) * (1 / 0.02f))); } else {