Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by killerbat · Apr 03, 2013 at 10:52 PM · bce0005unknown-identifier

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();
 }
Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Benproductions1 · Apr 03, 2013 at 11:38 PM 0
Share

whats with the else if at the start of your code, thats should cause some errors!

avatar image Benproductions1 · Apr 03, 2013 at 11:40 PM 1
Share

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

avatar image killerbat · Apr 04, 2013 at 12:18 AM 0
Share

else if (timerValue <= 0 && timerCoolDown > 0){

timerCoolDown -= Time.deltaTime;

Is where the errors are sorry didnt make that clear

avatar image EliteMossy · Apr 04, 2013 at 12:22 AM 0
Share

Never $$anonymous$$d, it was your weird layout

avatar image Statement · Apr 04, 2013 at 12:31 AM 0
Share

@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.

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

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;
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why Unknown identifier? 1 Answer

Unknown Identifier? 1 Answer

'Unknown Identifier' - cannot recognize other scripts 1 Answer

Script won't run level (platformer tutorial) 1 Answer

Problem with animation code or blender? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges