these scripts dont work for some reason, i wrote them mostly myself using references, but appearantly i did something i shouldnt have when writing them, my players doesnt get health as far as i know, and my damage script doesnt deal 10 points of damage to my player on collision. how could i fix it so that it does work?
//player Health script.js//
public var playerCurHp;
public var playerMaxHp;
playerCurHp = 100;
playerMaxHp = 100;
function ApplyDamage (damage : int) {
playerCurHp -= damage;
Debug.Log(playerCurHp);
if(playerCurHp > playerMaxHp){
playerCurHp = playerMaxHp;
}
if(playerCurHp < 0){
playerCurHp = 0;
}
if(playerCurHp < 1){
//die
// Die();
Debug.Log("YOU DIED!");
}
//function Die () {
//Application.LoadLevel (Application.loadedLevel);
}
//**apply damage script.js**//
var damage = 10;
function OnCollisionEnter (col : Collision) {
col.gameObject.BroadCastMessage("ApplyDamage", damage,
SendMessageOptions.DontRequireReceiver);
}