Lerp between Emission Values in Material Problems

I am trying to lerp between Red and Green emission values, however rather than a smooth transition I am getting a rough and fast color switch.

The code is below:

if (locked == false)] 
{
gameObject.GetComponentInChildren<Renderer>().material.SetColor("_EmissionColor", Color.Lerp(gameObject.GetComponentInChildren<Renderer>().material.GetColor("_EmissionColor"), Color.green, 200.0f));
}

Any ideas on what I am doing wrong?

Thanks for the help in advance!

It seems like your function calls is odd.

look at the docs for the function:

The last parameter should be a moving value from 0-1 to establish how much of each color is being used.

What you are doing here is lerping between emissioncolor & green, but your third param sets the value to 200.0f, which is clamped to 1, so it will just show green right away.
Note that the function takes 2 colors, not an RGB value.

Better usage will be :

private void float time;
void Start()
{
     time = 0;
}
void Update()
{
     time+=0.1f;
gameObject.GetComponentInChildren<Renderer>().material.SetColor("_EmissionColor", Color.Lerp(Insert begining color here , ending color you want, time));

}

you’d like to make the changes to the time variable according to the speed you want.