25 lines
653 B
C#
25 lines
653 B
C#
using System.Collections;
|
|
using UnityEngine;
|
|
|
|
public class EnviroLightning : MonoBehaviour
|
|
{
|
|
public void Lightning()
|
|
{
|
|
StartCoroutine(LightningBolt());
|
|
}
|
|
|
|
public IEnumerator LightningBolt()
|
|
{
|
|
GetComponent<Light>().enabled = true;
|
|
float defaultIntensity = GetComponent<Light>().intensity;
|
|
int flashCount = Random.Range(2, 5);
|
|
for (int thisFlash = 0; thisFlash < flashCount; thisFlash++)
|
|
{
|
|
GetComponent<Light>().intensity = defaultIntensity * Random.Range(1f, 1.5f);
|
|
yield return new WaitForSeconds(Random.Range(0.05f, 0.1f));
|
|
GetComponent<Light>().intensity = defaultIntensity;
|
|
}
|
|
GetComponent<Light>().enabled = false;
|
|
}
|
|
}
|