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
0
Question by epichi123 · Feb 16, 2014 at 06:30 PM · script errorpause menuno errorsimple fix

How to fix error BCE0005: Unknown identifier

I'm making a zombie apocalypse game. I copied some code from http://www.instructables.com/id/Intro-to-Unity/step13/HUD-and-Menu-system/ and http://www.instructables.com/id/Intro-to-Unity/step7/LockHide-Cursor/. Then 3 errors popped up:

Assets/scripts/Menu.js(24,5): BCE0005: Unknown identifier: 'DrawCrosshair'.

 DrawCrosshair();

Assets/scripts/Menu.js(36,38): BCE0005: Unknown identifier: 'Player'.

 var health = player.GetComponent(Player).Health;

Assets/scripts/Menu.js(47,5): BCE0005: Unknown identifier: 'DrawCrosshair'.

DrawCrosshair();

Here is all of the code:

  // True if the menu is open and mouse is unlocked
 var MenuOpen : boolean = false;
 
 function Start () {
     UpdateCursorLock();
 }
 
 function Update() {
     // Check whether the menu button was released
     if (Input.GetButtonUp("MenuOpen")) {
         MenuOpen = !MenuOpen;
         UpdateCursorLock();
     }
 }
 
 // Called each time the Gui needs to be drawn
  // Called each time the Gui needs to be drawn
 function OnGUI () {
     if (!MenuOpen) {
         DrawHUD();
     } else {
         DrawMenu();
     }
     DrawCrosshair();
 }
 
 function UpdateCursorLock() {
     Screen.lockCursor = !MenuOpen;
     Screen.showCursor = MenuOpen;
 }
 
  function DrawHUD() {
     
     // Get the health from the player
     var player = GameObject.Find("Player");
     var health = player.GetComponent(Player).Health;
 
     // Position
     var left = 10;
     var top = 10;
     var width = 100;
     var height = 25;
     
     // Make a background box
     GUI.Box (Rect (left, top, width, height), "Health: " + health);
     
     DrawCrosshair();
 }
 
 // Draw the menu
 function DrawMenu() {
     var centerX = Screen.width/2;
     var centerY = Screen.height/2;
     
     // location of the menu
     var menuLeft = centerX - 50;
     var menuTop = centerY - 50;
     var menuWidth = 100;
     var menuHeight = 100;
     
     var buttonX = menuLeft + 10;
     var buttonWidth = 80;
     var buttonHeight = 20;
     var buttonDist = 25; // distance between each button
     
     // Make a background box
     GUI.Box (Rect (menuLeft, menuTop,menuWidth,menuHeight), "Menu");
     
     // Start / Resume
     if (GUI.Button (Rect (buttonX,menuTop + 1 * buttonDist,buttonWidth,buttonHeight), "Resume")) {
         MenuOpen = false;
         UpdateCursorLock();
     }
     
     // Restart
     if (GUI.Button (Rect (buttonX,menuTop + 2 * buttonDist,buttonWidth,buttonHeight), "Restart")) {
         Application.LoadLevel(Application.loadedLevel);
     }
     
     // Quit (Only works in the Build. Does not work in the eidtor!)
     if (GUI.Button (Rect (buttonX,menuTop + 3 * buttonDist,buttonWidth,buttonHeight), "Quit")) {
         Application.Quit();
     }
 }
Comment
Add comment · Show 11
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 epichi123 · Feb 17, 2014 at 01:47 AM 0
Share

I kinda new so what does function DrawCrosshair() { mean.

Also what code do you think is missing,I got it from a website so I am not sure what would be missing. Thanks so far. :)

avatar image haim96 · Feb 17, 2014 at 08:20 AM 0
Share

well, it seems you missing more then just code... i strongly recommend you to go through some basic tutorials before jumping the water of writing code. copy-paste is nice but you must understand what you copy and where to paste it...

if you haven't seen this before: http://unity3d.com/learn/tutorials/modules

avatar image epichi123 · Feb 18, 2014 at 12:19 AM 0
Share

could you please just tell me what I might be missing.

avatar image haim96 · Feb 18, 2014 at 07:23 AM 0
Share

i will take a look at this later today since the site you copied the code from is blocked from my office.

avatar image epichi123 · Feb 18, 2014 at 11:23 PM 0
Share

Ok, thanks a lot. :) And it would be nice if you could do it by 3:45 but you don't have to. And you have an office? I'm not even a teenager!

Show more comments

1 Reply

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

Answer by haim96 · Feb 16, 2014 at 08:03 PM

you are missing some functions. look for code parts start look like this:

 function DrawCrosshair() {
 
 some code....
 
 }

Comment
Add comment · Show 1 · 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
avatar image haim96 · Feb 16, 2014 at 08:05 PM 0
Share

same for the Player,you are missing code parts...

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

20 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Monodevelop Error- Unity 4.3 0 Answers

Error building Player because scripts had compiler errors 0 Answers

Error with pause menu script. 0 Answers

how can i fix NSIS error in intall unity 4.3.0? 0 Answers

What's wrong with this physicscript? 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