I have my script done so that it spawns enemies which the player can fight and they will attack him. The problem is that because the enemies use the same script there's no way to indicate if the player's health has gone down without the collision defining whether he's been hit or not is static. Don't get me? Here's what I mean:
If 2 enemies are attacking the Player, because the hitTime is static, only 1 will hit him.
How can I change it so that both enemies will hit the Player?
Variable
static var hitTimeWeak:boolean = false;
Enemy Script:
function Attack()
{
isAttacking = true;
if(isAttacking == true && beingHit == false)
{
yield WaitForSeconds(WeakAttackSpeed);
hitTimeWeak = true;
animation.CrossFade("attack1");
yield WaitForSeconds(.5);
hitTimeWeak = false;
yield WaitForSeconds(.8);
animation.Stop();
hitTimeWeak = false;
isAttacking = false;
}else{
isAttacking = false;
}
}
Player Getting Hit:
function OnTriggerEnter(hitWeak : Collider)
{
if(hitWeak.gameObject.tag == "StalfosWeak" && Enemy1.hitTimeWeak == true)
{
HealthBar.HEALTH -= 1;
}
}