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

ERROR: BCE0019: 'enabled' is not a member of 'UnityEngine.GameObject'.

$
0
0
Ok, So in my game the main character has to use matches to light a fire. Here is my script: var batterySound : AudioClip; private static var batteryPower : float = 10; var Matches : GameObject; var Fire : GameObject; private var hasPlayed = false; function Start() { gameObject.enabled = false; } function OnTriggerEnter (c : Collider) { buttonInRange = true; } function OnTriggerExit (c : Collider) { buttonInRange = false; } function OnGUI () { if (buttonInRange == true) { if (Matches == false) { GUI.Label (Rect (Screen.width/2-50, Screen.height/2-55, 120, 50), "Use matches"); } } } function Update () { if (buttonInRange == true) { if (Input.GetKeyDown ("e")) { if(!hasPlayed) { AudioSource.PlayClipAtPoint(batterySound, transform.position); gameObject.enabled = false; hasPlayed = true; } } } } It all works fine except when I go to play it, I get the error Assets/FireStart.js(46,44): BCE0019: 'enabled' is not a member of 'UnityEngine.GameObject'. in lines 15 and 55... when I try to get rid of this error, the game plays but the fire is automatically on. Just to recap, what I want is an empty fireplace and the character collects matches (this collection part works fine) and then when the player gets close enough to the fireplace it displays "use matches" (which also works perfectly) and when the player presses "E", the fire will be lit (DOES NOT WORK).... I have no idea what is wrong.... Thanks

Viewing all articles
Browse latest Browse all 2891

Trending Articles



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