Exemple #1
0
    void Explode()
    {
        explosionSound.Play();
        GameObject explosionObject = Instantiate(explosionEffect, transform.position, transform.rotation) as GameObject;

        explosionObject.transform.localScale = new Vector3(explosionSize, explosionSize, explosionSize);
        Destroy(explosionObject, 1.9f);

        Collider[] colliders = Physics.OverlapSphere(transform.position, radius);

        foreach (Collider nearbyObject in colliders)
        {
            Rigidbody rb = nearbyObject.GetComponent <Rigidbody>();

            /*if (rb != null)
             * {
             *  rb.AddExplosionForce(force, transform.position, radius);
             * }*/

            if (nearbyObject.tag == "bozu")
            {
                GhostScript ghost = nearbyObject.GetComponent <GhostScript>();
                if (ghost != null)
                {
                    ghost.Die();
                }
            }
        }
        Destroy(gameObject);
    }