コード例 #1
0
    void OnCollisionEnter(Collision collision)
    {
        Vector3 loc    = collision.contacts[0].point;
        string  hitTag = collision.gameObject.tag;

        if (hitTag == "Untagged")
        {
            Destroy(gameObject);
            GameObject  obj = Instantiate(explosionFXObject, loc, Quaternion.identity);
            ExplosionFX fx  = obj.GetComponent <ExplosionFX>();
            fx.ExplodeWithDecal(false);
            Explode(loc);
        }
        else if (hitTag == "Floor")
        {
            Destroy(gameObject);
            GameObject  obj = Instantiate(explosionFXObject, loc, Quaternion.identity);
            ExplosionFX fx  = obj.GetComponent <ExplosionFX>();
            fx.ExplodeWithDecal(true);
            Explode(loc);
        }
    }