void OnTriggerExit2D(Collider2D collider) { if (collider.tag == "Player") { //Debug.Log(collider.name + " triggered me"); mib = transform.gameObject.GetComponent<MIB>(); if(mib != null) { mib.animator.SetBool ("Shooting", false); } } }
void OnCollisionEnter2D(Collision2D hit) { if (hit.gameObject.tag != "Player") { if (hit.collider.isTrigger == false) { //Debug.Log ("We hit " + other.name + " and did Test damage."); if(transform.gameObject.tag != "Player"){ if (hit.collider.tag == "Enemy") { soldier = hit.collider.gameObject.GetComponent<Soldier>(); mib = hit.collider.gameObject.GetComponent<MIB>(); dozer = hit.collider.gameObject.GetComponent<Bulldozer>(); if(soldier != null) { Debug.Log("hit"); soldier.DecreaseHealth(Damage); } if(mib != null) { Debug.Log("hit"); mib.DecreaseHealth(Damage); } if(dozer != null) { Debug.Log("hit"); dozer.DecreaseHealth(Damage); } } } } } /* else if (other.tag != "Player") { Destroy (gameObject); Debug.Log ("You were hit"); playerGameObj = GameObject.Find("Player"); player = playerGameObj.GetComponent<Player>(); player.DecreaseHealth(Damage); } */ }
void OnTriggerStay2D(Collider2D collider) { if (collider.tag == "Player") { //Debug.Log(collider.name + " triggered me"); if (Time.time > timeToFire) { timeToFire = Time.time + 1 / fireRate; mib = transform.gameObject.GetComponent<MIB>(); if(mib != null) { Debug.Log("MIB"); mib.animator.SetBool("Shooting", true); Shoot(); } else{ Shoot(); } } } }