Skip to content

Commit

Permalink
Improved lerping behaviour on the FogAdjustment.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
orels1 committed Sep 6, 2020
1 parent 4f9e069 commit 882873c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Misc/FogAdjustment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ void Start() {
}

private void StartLerping() {
if (lerping) {
active = !active;
}
lerping = true;
lerpEnd = Time.time + fogTransitionTime;
fromColor = RenderSettings.fogColor;
Expand Down Expand Up @@ -166,7 +169,6 @@ private void Update() {
var alpha = (Time.time - (lerpEnd - fogTransitionTime)) / fogTransitionTime;
// if currently active - lerp down;
if (active) {
Debug.Log("lerping down");
if (mode == FogMode.Linear) {
LerpFogLinear(fromColor, defaultFogColor, fromStart, defaultFogStart, fromEnd, defaultFogEnd,
alpha);
Expand All @@ -176,7 +178,6 @@ private void Update() {
}
} // otherwise - lerp up;
else {
Debug.Log("lerping up");
if (mode == FogMode.Linear) {
LerpFogLinear(fromColor, activeFogColor, fromStart, activeFogStart, fromEnd, activeFogEnd,
alpha);
Expand All @@ -187,7 +188,6 @@ private void Update() {
}

if (!(Time.time > lerpEnd)) return;
Debug.LogFormat("Reached lerp end, resetting {0}, current {1}", lerpEnd, Time.time);
lerping = false;
active = !active;
}
Expand Down

0 comments on commit 882873c

Please sign in to comment.