Error:
Assets/_SCRIPTS/playerBrain.js(164,33): BCE0051: Operator ‘-’ cannot be used with a left hand side of type ‘int’ and a right hand side of type ‘Object’.
SCRIPT:
public function damage(dmg) {
if(!health == 0) {
health = health - dmg;
}
if(health > 1) {
die();
}
}
Your variable Health is int, and so dmg should be, you need to declare what type of variable is dmg. So basically both variable types must be the same, int, float or other.
public function damage(dmg : int) {
health -= dmg;
if(health <= 0) {
health = 0;
die();
}
}