Пример #1
0
    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();
            }
        }
    }