void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.tag.Equals("FriendlyBullet")) { FriendlyBullet b = col.gameObject.GetComponent <FriendlyBullet>(); //Debug.Log(col.gameObject.GetComponent<Rigidbody2D>().velocity); if (b != null) { float dmg = b.getSpeed() / 5; health -= dmg; Debug.Log("lost " + dmg + " health"); } } }
void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag.Equals("FriendlyBullet")) { FriendlyBullet b = col.gameObject.GetComponent <FriendlyBullet>(); //Debug.Log(col.gameObject.GetComponent<Rigidbody2D>().velocity); if (b != null) { recentlyHit = true; float dmg = b.getSpeed() / 5; health -= dmg; //Debug.Log("lost " + dmg + " health"); Destroy(col.gameObject); } } }
void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag.Equals("FriendlyBullet")) { FriendlyBullet b = col.gameObject.GetComponent <FriendlyBullet>(); //Debug.Log(col.gameObject.GetComponent<Rigidbody2D>().velocity); if (b != null) { float dmg = b.getSpeed() / 5; health -= dmg; //Debug.Log("lost " + dmg + " health"); Destroy(col.gameObject); } } else if (col.gameObject.tag.Equals("Player")) { Spawner.enemiesAlive--; Spawner.enemiesKilled++; Destroy(this.gameObject); } }
void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag.Equals("FriendlyBullet")) { FriendlyBullet b = col.gameObject.GetComponent <FriendlyBullet>(); //Debug.Log(col.gameObject.GetComponent<Rigidbody2D>().velocity); if (b != null) { int x = Random.Range(0, 3); if (x == 0) { GameObject healthPack = Instantiate(hp, transform.position, Quaternion.identity) as GameObject; } Spawner.enemiesAlive--; Spawner.enemiesKilled++; float dmg = b.getSpeed() / 5; Destroy(this.gameObject); Destroy(col.gameObject); } } }