In this part of my script, should the debug log not print this1, 2, and 3 each time it hits the requirement? I think this is the reason my script isn’t working properly. It does debug log the health near the bottom of the script every time it hits the requirement though. Sorry if the coding is extremely dirty.
function OnCollisionEnter(other : Collision) {
if(other.collider.GetComponent(HealthSystem)) {
Debug.Log("This1");
HealthS = other.collider.GetComponent(HealthSystem);
Debug.Log("This2");
Health = HealthS.Central.GetComponent(CentralHealth).Health;
Debug.Log("This3");
Debug.Log(Health);
if(HealthS.IsHead == true) {
Debug.Log("Hit something!");
Health -= Damage;
}
if(HealthS.IsTorso == true) {
Debug.Log("Hit something!");
Health -= Damage / 2;
}
if(HealthS.IsArm == true) {
Health -= Damage / 3;
}
if(HealthS.IsLeg == true) {
Health -= Damage / 2.5;
}
if(HealthS.IsOther == true) {
Health -= Damage / 2;
}
Debug.Log(Health);
}
else {
Debug.Log(other.collider.name + " Does not have HealthSystem script attached! ");
}
//if(hit.gameObject.tag != "Metal" && hit.gameObject.tag != "Wood" && hit.gameObject.tag != "Stone" && hit.gameObject.tag != "Dirt") {
//}
Destroy (gameObject);
}