public bool LightOn = false;
public Light Light1;
void Start()
{
Light1 = GetComponent<Light>();
StartCoroutine(LightTimer());
}
// Update is called once per frame
void Update()
{
Lighter();
}
void Lighter()
{
if (LightOn)
{
Light1.intensity = Random.Range(3, 5);
}
}
IEnumerator LightTimer()
{
while(true)
{
LightOn = !LightOn;
yield return new WaitForSeconds(0.5f);
}
}
This is the result. Can be slightly better if you play with the intensity and wait time.