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?
↧