Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

i cant fix the error BCE0023?!!!!

$
0
0
Hi, I am new to coding and i cant solve this error(Assets/Inventory/Inv.js(23,74): BCE0023: No appropriate version of 'UnityEngine.GameObject.GetComponent' for the argument list '(GUISurvival)' was found.) I am creating an inventory and am linking it to my player stats. Here are my scripts: Inv.js: var menuSkin : GUISkin; var wood : int= 0; var stone : int=0; var rope : int=0; var food : int=0; var water : int=0; var bandage : int=0; private var showGUI : boolean = false; private var GUISurvival : GUISurvival; var minimumVal : int = 0; function Start() { GUISurvival = GameObject.Find("First Person Controller").GetComponent(GUISurvival); } function Update() { if(wood <= 0) { wood = minimumVal; } if(rope <= 0) { stone = minimumVal; } if(rope <= 0) { rope = minimumVal; } if(food <= 0) { food = minimumVal; } if(water <= 0) { water = minimumVal; } if(bandage <= 0) { bandage = minimumVal; } if(Input.GetKeyDown("e")) { showGUI = !showGUI; } if(showGUI == true) { Time.timeScale = 0; GameObject.Find("First Person Controller").GetComponent(FPSInputController).enabled = false; GameObject.Find("First Person Controller").GetComponent(MouseLook).enabled = false; GameObject.Find("Main Camera").GetComponent(MouseLook).enabled = false; } if(showGUI == false) { Time.timeScale = 0; GameObject.Find("First Person Controller").GetComponent(FPSInputController).enabled = true; GameObject.Find("First Person Controller").GetComponent(MouseLook).enabled = true; GameObject.Find("Main Camera").GetComponent(MouseLook).enabled = true; } } function OnGUI() { if(showGUI == true) { GUI.skin = menuSkin; GUI.BeginGroup(new Rect(Screen.width / 2 - 150, Screen.height / 2 - 150, 300, 300)); GUI.Box(Rect(0, 0, 300, 300), "Inventory"); //Resources Collected GUI.Label(Rect(10, 50, 50, 50), "Wood"); GUI.Box(Rect(60, 50, 20, 20), "" + wood); GUI.Label(Rect(90, 50, 50, 50), "Stone"); GUI.Box(Rect(130, 50, 20, 20), "" + stone); GUI.Label(Rect(170, 50, 50, 50), "Rope"); GUI.Box(Rect(200, 50, 20, 20), "" + rope); //Usable items GUI.Label(Rect(10, 190, 50, 50), "Food"); GUI.Box(Rect(60, 190, 20, 20), "" + food); if(GUI.Button(Rect(100, 190, 100, 20), "Eat Food?")) { food--; Eat(); } GUI.Label(Rect(10, 210, 50, 50), "Water"); GUI.Box(Rect(60, 210, 20, 20), "" + water); if(GUI.Button(Rect(100, 210, 100, 20), "Drink Water?")); { water--; Drink(); } GUI.Label(Rect(10, 240, 50, 50), "plaster"); GUI.Box(Rect(60, 240, 20, 20), "" + bandage); if(GUI.Button(Rect(100, 240, 100, 20), "Heal?")); { bandage--; Heal(); } GUI.EndGroup(); } } function Eat() { GUISurvival.currentHunger += 20; } function Drink() { GUISurvival.currentThirst += 20; } function Heal() { GUISurvival.currentHealth += 20; } ------------------------------------------------------- ------------------------------------------------------- GUISurvival.js: function Update() { if(currentHealth <= 0) { CharacterDeath(); } /* THIRST CONTROL SECTION*/ //Normal thirst degredation if(currentThirst >= 0) { currentThirst -= Time.deltaTime / 2; } if(currentThirst <= 0) { currentThirst = 0; } if(currentThirst >= maxThirst) { currentThirst = maxThirst; } /* HUNGER CONTROL SECTION*/ if(currentHunger >= 0) { currentHunger -= Time.deltaTime / 4; } if(currentHunger <= 0) { currentHunger = 0; } if(currentHunger >= maxHunger) { currentHunger = maxHunger; } /* DAMAGE CONTROL SECTION*/ if(currentHunger <= 0 && (currentThirst <= 0)) { currentHealth -= Time.deltaTime / 2; } else { if(currentHunger <= 0 || currentThirst <= 0) { currentHealth -= Time.deltaTime / 4; } } } function CharacterDeath() { Application.LoadLevel("SimpleMenu"); } function OnGUI() { //Icons GUI.Box(new Rect(5, 30, 50, 23), "Health"); GUI.Box(new Rect(5, 55, 50, 23), "Thirst"); GUI.Box(new Rect(5, 80, 50, 23), "Hunger"); //Health / Hunger / Thirst bars GUI.Box(new Rect(55, 30, barLength, 23), currentHealth.ToString("0") + "/" + maxHealth); GUI.Box(new Rect(55, 55, barLength, 23), currentThirst.ToString("0") + "/" + maxThirst); GUI.Box(new Rect(55, 80, barLength, 23), currentHunger.ToString("0") + "/" + maxHunger); }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>