- Home /
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();
}
}
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. :)
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
i will take a look at this later today since the site you copied the code from is blocked from my office.
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!
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....
}
Your answer
Follow this Question
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