using UnityEngine; using System.Collections; public class Explosion : MonoBehaviour{ [Header("Kinetic force that will be applied to any object caught in the blast ")] public int Pull_Force=1; [Header("Damage that will be dealt to any object caught in the blast ")] public int Damage=1; [Header("This is the area of effect of the explosion")] public float range_Effect=1; [Header("This timer controls for how long will the effect exist, used mostly for cleanup and optimization")] public float duration=1; void Awake(){ ///ORIENTATE TOWARDS FLOOR if(duration>0){Destroy (gameObject, duration);} } void Start(){ Vector3 explosionPos = transform.position; Collider[] colliders = Physics.OverlapSphere(explosionPos, range_Effect); foreach (Collider hit in colliders) { if(hit.GetComponent()){ Rigidbody rb = hit.GetComponent(); rb.AddExplosionForce(Pull_Force, explosionPos, range_Effect, 3.0F); } if(hit.GetComponent()){ Life LiV = hit.GetComponent(); LiV.Be_Hitten(Damage); } } } }