- Home /
BCE0005: Unknown identifier
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();
}
whats with the else if
at the start of your code, thats should cause some errors!
Also you re using timerCoolDownValue
and then you start using timerCoolDown
, which is not defined. Either define it, or change it, thats should solve your problem
else if (timerValue <= 0 && timerCoolDown > 0){
timerCoolDown -= Time.deltaTime;
Is where the errors are sorry didnt make that clear
@Elite$$anonymous$$ossy: No, the first two lines are not part of the code. I also thought it was something odd like that but as @killerbat commented, it was just to highlight where in the code the line 23 and 24 is.
Answer by Statement · Apr 04, 2013 at 12:30 AM
get an unknown identifier on line 23 and 24.*
An unknown identifier means that there is a name (identifier) that the compiler doesn't recognize. It is because you haven't written the code for it or perhaps changed the name of a variable in one place and forgot to do it in another. This is most often due to a spelling error in your code, or that you try to access an identifier that exists in scope you don't have access to. In this case it appears to be a typo that you have made, because there is no variable called timerCoolDown
as the error says.
BCE0005: Unknown identifier: 'timerCoolDown'.
The closest ones that appear to be the ones you wanted to use is in the field declarations:
var timerCoolDownStart : float = 40;
var timerCoolDownValue : float = 0;
As you see, you don't have timerCoolDown
defined in the code, yet you are trying to use it.
// BCE0005: Unknown identifier: 'timerCoolDown'.
else if (timerValue <= 0 && timerCoolDown > 0){
// BCE0005: Unknown identifier: 'timerCoolDown'.
timerCoolDown -= Time.deltaTime;
Your answer
Follow this Question
Related Questions
Why Unknown identifier? 1 Answer
Unknown Identifier? 1 Answer
'Unknown Identifier' - cannot recognize other scripts 1 Answer