single color lerp

i have made a scrtipt witch lerps between a bunch of colors but i only want to change it when one of the colors hat reached its mark.

the problem is that it does not stop lerping.

this is the code without the color switching. i just need to return false to a bool to change the colors.

void Update () {

		if (LerpColorBool == true)

	void LerpColor()
				float t = Mathf.PingPong (Time.time, duration) / duration;
				RenderSettings.fogColor = Color.Lerp (fogColor1, fogColor2, t);
				RenderSettings.ambientLight = Color.Lerp (ambColor1, ambColor2, t);
				DirectionalLight.light.color = Color.Lerp (ambColor1, ambColor2, t);
				if (RenderSettings.fogColor == fogColor2 || RenderSettings.fogColor == fogColor1)
 						LerpColorBool = false;

If I were you, I would save the time when the lerp starts:

LerpColorBool = true;
Float time = Time.time;

Then I would replace this float t =… to:

float t = (Time.time-time)/durstion;
if (t > 1) t = 1;

Also you shoudn’t check the colors at the end, rather the time:

if (t>=1) LerpColorBool = false;