示例#1
0
    void OnCollisionEnter2D(Collision2D col)
    {
        MetaAsteroids_Asteroid asteroid = col.gameObject.GetComponent <MetaAsteroids_Asteroid>();

        if (asteroid != null && asteroid.gameObject.activeSelf)
        {
            gameObject.SetActive(false);
            asteroid.OnHitByBullet();
        }
    }
    void OnCollisionEnter2D(Collision2D col)
    {
        MetaAsteroids_Asteroid asteroid = col.gameObject.GetComponent <MetaAsteroids_Asteroid>();

        if (asteroid != null && asteroid.gameObject.activeSelf)
        {
            OnHitAsteroid();
        }
        else
        {
            MetaAsteroids_Bullet bullet = col.gameObject.GetComponent <MetaAsteroids_Bullet>();
            if (bullet != null && bullet.gameObject.activeSelf)
            {
                OnHitByBullet();
            }
        }
    }