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

Assets/Eat_Meat.js(27,14): BCE0020: An instance of type 'UnityEngine.Component' is required to access non static member 'gameObject'.

$
0
0
I am making a game in which you eat to survive. i have a code which when you walk near a box (which will become food) it has a certain amount of food which will decay every second you stand near it and eat. Here is the code private var Meatfood:int = (15); function OnTriggerEnter (other:Collider) { if (Collider.gameObject.tag == "Player") { Meatfood=(Meatfood - 1); yield WaitForSeconds(0.1); if (Meatfood <= 0) { Destroy (gameObject); } } } But the Error pops up and i've tried everything, it worked when i had private var Meatfood:int = (15); but then i took out the "private" and it broke, so i placed it back in and now wont work at all. any ideas?

Viewing all articles
Browse latest Browse all 7934

Trending Articles



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