FTME01_RandomLight.js 509 B

123456789101112131415161718
  1. #pragma strict
  2. var minFlickerIntensity : float = 2;
  3. var maxFlickerIntensity : float = 5;
  4. var flickerSpeed : float = 0.7;
  5. private var randomizer : int = 0;
  6. while (true)
  7. {
  8. if (randomizer == 0) {
  9. GetComponent.<Light>().intensity = (Random.Range (minFlickerIntensity, maxFlickerIntensity));
  10. }
  11. else GetComponent.<Light>().intensity = (Random.Range (minFlickerIntensity, maxFlickerIntensity));
  12. randomizer = Random.Range (0, 1.1);
  13. yield WaitForSeconds (flickerSpeed);
  14. }