private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("Meteoritos")) { Meteoritos meteoritos = collision.gameObject.GetComponent <Meteoritos>(); if (meteoritos != null) { FindObjectOfType <Score>().AddPoints(10); Destroy(collision.gameObject); Destroy(this.gameObject); GameObject particles = Instantiate(hitparticlePrefab, transform.position, transform.rotation); Destroy(particles, 5f); Destroy(this.gameObject); } } else if (collision.gameObject.CompareTag("Enemy")) { Enemy enemy = collision.gameObject.GetComponent <Enemy>(); if (enemy != null) { FindObjectOfType <Score>().AddPoints(10); enemy.Damage(damageAmount); GameObject particles2 = Instantiate(hitparticlePrefab, transform.position, transform.rotation); Destroy(particles2, 1f); Destroy(this.gameObject); } } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("Player")) { Player player = collision.gameObject.GetComponent <Player>(); if (player != null) { player.Damage(damageAmount); } } else if (collision.gameObject.CompareTag("Meteoritos")) { Meteoritos meteoritos = collision.gameObject.GetComponent <Meteoritos>(); if (meteoritos != null) { meteoritos.DestroyMeteoritos(); GameObject particlesEnemy = Instantiate(hitParticlePrefab, transform.position, transform.rotation); Destroy(particlesEnemy, 1f); Destroy(this.gameObject); } } GameObject particles = Instantiate(hitParticlePrefab, transform.position, transform.rotation); Destroy(particles, 1f); Destroy(this.gameObject); }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Meteoritos")) { Meteoritos meteoritos = collision.gameObject.GetComponent <Meteoritos>(); if (meteoritos != null) { FindObjectOfType <Score>().AddPoints(10); Destroy(collision.gameObject); Destroy(this.gameObject); } } }