Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
This question was closed Oct 16, 2016 at 04:10 PM by Hellium for the following reason:

This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers.

avatar image
0
Question by ZBlaxland · Oct 16, 2016 at 04:02 PM · gameobjecterror messagefireenabledmember

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

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

Comment
Add comment · Show 1
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 Hellium · Oct 16, 2016 at 04:08 PM 0
Share

FAQ :

Some reasons for getting a post rejected:

  • Posting about a specific compiling error or NullReferenceException: there is a myriad of these questions with answers already, have a look at those posts to get hints on what could possibly be your issue. Also, take a look at the Unity's support website, many errors and how to solve them are described here

2 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by doublemax · Oct 16, 2016 at 04:09 PM

Compilers usually don't lie and when you check the documentation for GameObject, you'll see that it doesn't have a public variable "enabled".

Try gameObject.SetActive(false);

However, if you'd call SetActive(false) in Start(), Update() would never get called. So i'm not sure if that's what you actually want to do.

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 ZBlaxland · Oct 17, 2016 at 12:41 AM 0
Share

It worked but you're right, update no longer works.... It's definitely a start though, I'll just fiddle with it for a bit

avatar image
1

Answer by Lilius · Oct 16, 2016 at 04:10 PM

Try this: gameobject.SetActive(true); gameobject.SetActive(false);

Comment
Add comment · Show 2 · 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 RockingGameDeveloper · Sep 23, 2018 at 03:33 AM -1
Share

This is not what he meant.

EX: If an object attached to a camera is set from true to false, and the player walks around and then sets the object to true, the object attached to the camera will not be positioned in front of the camera.

avatar image Lilius RockingGameDeveloper · Sep 23, 2018 at 11:03 AM 0
Share

Thats excatly what he meant, and that is excatly how game objects are enabled/disabled. Same answer is also in accepted answer. JavaScript is not supported anymore and this is two years old question.

Follow this Question

Answers Answers and Comments

6 People are following this question.

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

Related Questions

BCE0019: 'gameObject' is not a member of 'Object'. 1 Answer

Unity bug gives false error messages or doesen't work without a Debug.Log() line present 1 Answer

MissingReferenceException: The object of type 'Animator' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. 2 Answers

var script : GameObject 2 Answers

How do you fix NullReferenceException: Object reference not set to an instance of an object... errors? 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