Ok so I have two enemies they are the same objects/models and same exact script. As you can see I gave the hands a empty with a collider to use it for a hit box. So when I play the game with just one enemy it works perfect but when I throw 2 or more. Only 1 enemy can hurt the player. here is my code
void OnTriggerEnter(Collider other){
if (other.gameObject.tag == "EnemyHitbox" && GameObject.FindGameObjectWithTag("EnemyBot").GetComponent().attacking) {
Debug.Log ("YOU BEEN HIT BY "+HitBox.BoxType+" Damage Delt: "+HitBox.Damage);
//if(HP > 0){
//}
if(!dead){
//transform.LookAt(targetPlayer);
//GETs knocked back
if(!playerSFX.isPlaying)
{
playerSFX.clip = playerClips[3];
playerSFX.Play();
}
animator.Play("HIT_BODY");
transform.Translate (-Vector3.forward*2 * Time.deltaTime);
}
//rigidbody.rotation = targetPlayer.rotation*-1;
//rigidbody.AddForce (-Vector3.forward*200,ForceMode.Acceleration);
//HP-=HitBox.Damage;
HP-=other.gameObject.GetComponent().damage;
}
}
[1]: http://puu.sh/cdkrk/c450c6bb0c.jpg
↧