greetings
i’m trying to make hp for a wall, but i want to have each enemy hitting the wall doing damage separately (and having a separate attackcooldown timer for each one), does anyone know how i can make one?
i have this:
private int HP;
private List<Transform> enemies = new List<Transform>();
void OnCollisionEnter(Collision hit){
enemies.Add (hit.gameObject);
}
void OnCollisionStay(Collision collide){
if (collide.gameObject.tag == "Enemy2") {
HP -= 10;
} else if (collide.gameObject.tag == "Enemy1") {
HP -= 5;
}
if (HP <= 0) {
Destroy(this.gameObject);
}
}