help my code is not working can you please fix it for me unity says unexpected token health
var health : float = 50;
var Damage : float = 10;
var Player : GameObject;
function OnCollisionEnter(collision : Collision) health - Damage;
if (health <= 0) {
Destroy (Player);
}
you seem to be missing opening and closing bracket for OnCollissionEnter
var health : float = 50;
var Damage : float = 10;
function OnCollisionEnter(collision : Collision)
{
health - Damage;
if (health <= 0) {
Destroy ("Player");
}//end if
}//end OnCollisionEnter
var health : float = 50;
var Damage : float = 10;
function OnCollisionEnter (collision : Collision) {
health = health - Damage;
if (health <= 0) {
Destroy (gameObject);
}
}
Destroy is probably not correct. You need to pass a game object to it. That means you somehow need to get the player’s game object here.