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 /
avatar image
0
Question by Zikovic · Jan 21, 2016 at 01:37 AM · errornewbiemessagemessagesmessagebox

need small help with error BCE0019

AssTrapBuild.js(40,47): BCE0019: 'trap' is not a member of 'Crafting'.

pragma strict

var MenuSkin : GUISkin;

//References var player : GameObject; var mainCamera : GameObject; var arms : GameObject;

//Icons var campfireIcon : Texture; var tentIcon : Texture; var spareIcon : Texture; var spareIcon2 : Texture; var spareIcon3 : Texture;

//Player prefabs var campFire : GameObject; var tent : GameObject; var trap : GameObject; var spare2 : GameObject; var spare3 : GameObject;

private var showGUI : boolean = false;

private var invScript : Inventory;

function Start() { invScript = GetComponent(Inventory); }

function Update() { if(Input.GetKeyDown("c")) { showGUI = !showGUI; }

 if(showGUI == true)
 {
     Time.timeScale = 0;
     player.GetComponent(FPSInputController).enabled = false;
     player.GetComponent(MouseLook).enabled = false;
     mainCamera.GetComponent(MouseLook).enabled = false;
     arms.GetComponent(PlayerControl).enabled = false;
 }
 
 if(showGUI == false)
 {
     Time.timeScale = 1;
     player.GetComponent(FPSInputController).enabled = true;
     player.GetComponent(MouseLook).enabled = true;
     mainCamera.GetComponent(MouseLook).enabled = true;
     arms.GetComponent(PlayerControl).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),"Crafting System");

             if(GUI.Button(Rect(10, 50, 50, 50), GUIContent (campfireIcon, "Build a campfire")))
             {
                 if(invScript.wood >= 6 && invScript.stone >= 3)
                 {
                     campFire.SetActive(true);
                     invScript.wood -= 6;
                     invScript.stone -= 3;
                 }
             }
             
             if(GUI.Button(Rect(10, 120, 50, 50), GUIContent    (tentIcon, "Build a tent?")))
             {
                 if(invScript.wood >= 10 && invScript.stone >= 5 && invScript.clay >= 3)
                 {
                     tent.SetActive(true);
                     invScript.wood -= 10;
                     invScript.stone -= 5;
                 }
             }
             
             
             //TRAP SECTION
             if(GUI.Button(Rect(10, 190, 50, 50), GUIContent(spareIcon, "Build a trap?")))
             {
                 if(invScript.wood >= 10 && invScript.stone >= 5)
                 {
                     trap.SetActive(true);
                     invScript.wood -= 10;
                     invScript.stone -= 5;
                 }
             }
             
             //SECOND COLUMN!
             if(GUI.Button(Rect(100, 50, 50, 50), GUIContent(spareIcon2, "Spare item tooltip!")))
             {
                 if(invScript.wood >= 10 && invScript.stone >= 5)
                 {
                     spare2.SetActive(true);
                     invScript.wood -= 10;
                     invScript.stone -= 5;
                 }
             }
             
             if(GUI.Button(Rect(100, 120, 50, 50), GUIContent(spareIcon3, "Spare item tooltip!")))
             {
                 if(invScript.wood >= 10 && invScript.stone >= 5)
                 {
                     spare3.SetActive(true);
                     invScript.wood -= 10;
                     invScript.stone -= 5;
                 }
             }
             
             GUI.Label (Rect (100, 250, 100, 40), GUI.tooltip);
             GUI.EndGroup ();
   }

} Codes up Are from Crafting.js script

Codes down here are from TrapBuild.js script #pragma strict

 var trapPrefab : Transform;
 var player : GameObject;
 
 private var canBuild : boolean = false;
 
 function Start()
 {
     GetComponent.<Renderer>().material.color = Color.red;
     GetComponent.<Renderer>().material.color.a = 0.5;
     player = GameObject.Find("First Person Controller");
 }
 
 function OnTriggerEnter(col : Collider)
 {
     if(col.gameObject.tag == "AnimalTrack")
     {
         GetComponent.<Renderer>().material.color = Color.green;
         GetComponent.<Renderer>().material.color.a = 0.5;
         canBuild = true;
     }
 }
 
 function OnTriggerExit(col : Collider)
 {
     if(col.gameObject.tag == "AnimalTrack")
     {
         GetComponent.<Renderer>().material.color = Color.red;
         GetComponent.<Renderer>().material.color.a = 0.5;
         canBuild = false;
     }
 }
 
 function Update()
 {
     if(Input.GetKeyDown("b") && canBuild == true)
     {
     //    Instantiate(trapPrefab, player.transform.position + Vector3(0, 0, 5), Quaternion.identity);
 //        player.GetComponent(Crafting).trap.SetActive(false);
     }
 }
Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

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

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

Related Questions

RE: Error Message 0 Answers

Error CS0120 : An object reference is required to access non-static member 3 Answers

[Help] I keep getting an error with empty message when I create a C# script 1 Answer

If statement not working correctly 1 Answer

Build an APK gets error 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