void Start() { EnemyTypo e = GetComponent <EnemyTypo>(); startingHealth = e.health; id = e.id; rigidbody = GetComponent <Rigidbody>(); capsuleCollider = GetComponent <CapsuleCollider>(); animator = GetComponent <Animator>(); isAlive = true; currrentHealth = startingHealth; dropItems = GetComponent <DropItems>(); }
void OnTriggerEnter(Collider other) { if (timer >= timeSinceLastHit && !GameManager.instance.GameOver) { if (other.tag == "Weapon") { EnemyTypo e = other.GetComponent <EnemyTypo>(); print("Collision HIt"); TakeHit(e.damage); timer = 0; } } }
void Start() { EnemyTypo e = GetComponent <EnemyTypo>(); startingHealth = e.health; Debug.Log(e.health); id = e.id; rigidbody = GetComponent <Rigidbody>(); capsuleCollider = GetComponent <CapsuleCollider>(); nav = GetComponent <NavMeshAgent>(); animator = GetComponent <Animator>(); isAlive = true; currrentHealth = startingHealth; weaponCollider = GetComponentInChildren <BoxCollider>(); dropItems = GetComponent <DropItems>(); }
void TakeHit(int damage, AmmoTypo t) { if (startingHealth == 0) { EnemyTypo e = GetComponent <EnemyTypo>(); startingHealth = e.health; currrentHealth = startingHealth; } if (currrentHealth > 0) { animator.Play("Hurt"); currrentHealth -= damage; } if (currrentHealth <= 0) { isAlive = false; KillEnemy(t); } }