Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void takeDamage(float damage)
- {
- health -= damage;
- if (health <= 0 ) {
- Destroy(gameObject);
- }
- -------------------------------------------------
- private void OnTriggerStay(Collider other){
- if (other.CompareTag("Attack"))
- {
- if (dmg == null)
- dmg = StartCoroutine(setDamage(other));
- }
- private void OnTriggerExit(Collider other){
- if (other.CompareTag("Attack"))
- {
- StopCoroutine(dmg);
- dmg = null;
- }
- IEnumerator setDamage(Collider other)
- {
- while(true)
- {
- //AttackMale = true;
- if (agent.enabled)
- other.transform.parent.GetComponent<PlayerHealth>().takeDamage(damage);
- yield return new WaitForSeconds(0.5f);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement