Hi I’m having probems with the collision on my zombie, here is the code for the collision.
var curHealth : int = 100;
var maxHealth : int = 100;
function OnCollisionEnter(hit : Collision) {
if(hit.transform.name == "ZOMBIE") {
curHealth -= 3;
Debug.Log("ok");
}
}
var healthtext : GUIText;
var regenActive = true;
function Start () {
healthRegen();
}
function Update () {
healthtext.text = curHealth + " / " + maxHealth;
if(curHealth < 0 ) {
Application.LoadLevel("NewOne");
}
if(curHealth > 100) {
curHealth = 100;
}
if(Input.GetKeyDown("e")) {
curHealth -= 101;
}
}
function healthRegen () {
while(regenActive==true) {
yield WaitForSeconds(0.5);
if(curHealth < maxHealth) {
curHealth++;
}
}
}
The zombie has a box collider, but when I touch it my health doesn’t go down, do I need change the propertes of the zombie or the actual script?