using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Explode : MonoBehaviour {

    public float Radius;
    public float Force;
    public float UpwardsForce;
	// Use this for initialization
	void OnEnable () {
        this.Invoke("BlowUp",0.01f);
	}
	

    void BlowUp()
    {
        Collider[] colliders = Physics.OverlapSphere(this.transform.position, Radius);

        for (int i=0; i<colliders.Length; i++)
        {
            Rigidbody rigidbody = colliders[i].GetComponent<Rigidbody>();
           
            if (rigidbody!=null)
            {
                rigidbody.isKinematic = false;
                rigidbody.AddExplosionForce(Force, this.transform.position, Radius, UpwardsForce, ForceMode.Impulse);
            }

        }

    }
	// Update is called once per frame
	void Update () {
		
	}
}
