Ok I’ve looked all over for a code to do this and I’ve been experimenting but nothing will work. So this is the script for the toggable flashlight:
var flashlight : Component;
var FlashLIghtOn : AudioClip;
var FlashLIghtOff : AudioClip;
function Start () {
flashlight = GetComponent("Light");
}
function Update () {
if (Input.GetMouseButtonDown(0)) {
if (flashlight.enabled) {
flashlight.enabled = false;
audio.PlayOneShot(FlashLIghtOn);
}
else {
flashlight.enabled = true;
audio.PlayOneShot(FlashLIghtOff);
}
}
}
and I want it to flicker only when its on. Any help? Heres my flickering light script if it helps:
var flickerSpeed : float = 0.07;
private var randomizer : int = 0;
while (true) {
if (randomizer == 0) {
light.enabled = false;
}
else light.enabled = true;
randomizer = Random.Range (0.1, 3.5);
yield WaitForSeconds (flickerSpeed);
}
Sorry I suck at code right now… Still learning