Why color isnt working in JS

I have a lerp system that changes the background color of the world to represent different times of day, but when I hit play the sky goes completely black, what did I do wrong?

#pragma strict

public var myCamera : Camera;

public var colorTime : float = 0;
public var turnTime = 0; /* 0 for day 1 for night */

var lerpedColor : Color = Color.cyan;
public var dayC : Color;
public var nightC : Color;

function Update() {
	lerpedColor = Color.Lerp(dayC, nightC, Mathf.PingPong(Time.time, colorTime));
	myCamera.backgroundColor = lerpedColor;
}

for DayC and nightC I went into the components and edited the color there, but the color still remains black when i hit play.

EDIT:
Here’s a pic of the problem with the component
Imgur

I am not sure why lerped color changes to black and gets that odd long white line

Your alpha values for both dayC and nightC are 0, making it invisible.

Are you sure you want this?

Mathf.PingPong(Time.time, colorTime)

Especially because it makes no sense when colorTime is 0.

@Dantus How else should I approach this? A lot of that script is going off of the help someone else gave me…

@DanielQuick And how do I change the alpha?

If you look at the scripting reference entry, you’ll see that it will return a value between 0 and the second parameter. In this case, since you are getting a value to use in a Lerp, you want a value between 0 and one. This means that the second parameter should be 1.

The same way you change the colors, there are 4 slides. Red, Green, Blue, and Alpha

So you mean that it should be (Time.time, 1) ?

colorTime is a variable I have it makes so it takes 225 seconds to get to…

Oh in the script I have colorTime set to 0.
I made it 225 through the component side panel thing

Thanks, worked perfectly! I feel kinda stupid lol.

Then the first parameter should be Time.time/colorTime

lerpedColor = Color.Lerp(dayC, nightC, Mathf.PingPong(Time.time/colorTime));

ERROR:

The best overload for the method ‘UnityEngine.Mathf.PingPong(float, float)’ is not compatible with the argument list ‘(float)’.

I said the first parameter, not the only parameter.

You need to learn to use the scripting reference and follow the error messages instead of blindly testing things out.

sorry