I get an unknown identifier on line 23 and 24. The error is here
else if (timerValue <= 0 && timerCoolDown > 0){
timerCoolDown -= Time.deltaTime;
This is my code:
private var lightSource : Light;
var soundTurnOn : AudioClip;
var soundTurnOff : AudioClip;
var timerStartValue : float = 30;
var timerValue : float = 0;
var timerCoolDownStart : float = 40;
var timerCoolDownValue : float = 0;
function Start () {
lightSource = GetComponent(Light);
timerValue = timerStartValue;
timerCoolDownValue = timerCoolDownStart;
}
function Update () {
if (Input.GetKeyDown(KeyCode.F) && timerValue > 0) {
ToggleFlashLight();
}
if (timerValue > 0 && timerCoolDownValue >= timerCoolDownStart){
timerValue -= Time.deltaTime;
}
else if (timerValue <= 0 && timerCoolDown > 0){
timerCoolDown -= Time.deltaTime;
lightSource.enabled = false;
audio.clip = soundTurnOff;
audio.Play();
}
else{
timerValue = timerStartValue;
timerCoolDownValue = timerCoolDownStart;
}
}
function ToggleFlashLight () {
lightSource.enabled=!lightSource.enabled;
//Audio
if (lightSource.enabled) {
audio.clip = soundTurnOn;
} else {
audio.clip = soundTurnOff;
}
audio.Play();
}