I'm using a gradient script to change the color of a sphere over time, but I want a point light associated to it to change too.
The script I'm using is this:
public class gradient : MonoBehaviour
{
public Gradient myGradient;
public float strobeDuration = 2f;
public void Update()
{
float t = Mathf.PingPong(Time.time / strobeDuration, 1f);
GetComponent<Renderer>().material.color= myGradient.Evaluate(t);
}
}
The light object accepts the script but it doesn't affect the color.
I assume it's because this script is associated to materials and light has no material...
Light
component instead of theRenderer
component, and assign the light's colour that way? \$\endgroup\$