trying to make health script, but it gives me this error "Expressions in statements must only be executed for their side-effects"
var player : GameObject;
var health = 1000;
function Start()
{
}
function Update()
{
if(health <= 0)
{
Debug.log("you are dead");
Destroy(player);
}
if(health >= 1000)
{
health = 1000;
}
}
function OnCollisionStay2D(coll: Collision2D)
{
if(coll.gameObject.tag == "Enemy")
{
health - 100; //says the error is on this line, but i don't know why.
}
}
↧