private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("meteorite")) { Meteorito meteorite = collision.gameObject.GetComponent <Meteorito>(); if (meteorite != null) { FindObjectOfType <Score>().AddPoints(10); Destroy(collision.gameObject); Destroy(this.gameObject); meteorite.DestroyMeteorite(); Destroybullet(); } } if (collision.gameObject.CompareTag("Enemigo")) { Enemigo enemigo = collision.gameObject.GetComponent <Enemigo>(); if (enemigo != null) { FindObjectOfType <Score>().AddPoints(10); Destroy(collision.gameObject); Destroy(this.gameObject); enemigo.DestroyEnemy(); Destroybullet(); } } }
private void OnCollisionEnter2D(Collision2D collision) { Player player = collision.gameObject.GetComponent <Player>(); if (player != null) { player.Damage(damageAmount); Destroy(this.gameObject); } if (collision.gameObject.CompareTag("meteorite")) { Meteorito meteorite = collision.gameObject.GetComponent <Meteorito>(); if (meteorite != null) { FindObjectOfType <Score>().AddPoints(10); Destroy(collision.gameObject); Destroy(this.gameObject); } } }