Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Explosion : MonoBehaviour
- {
- public float Radius;
- public float Force;
- void Update ()
- {
- Collider[] hitColliders = Physics.OverlapSphere(transform.position, Radius);
- for(int i=0; i<hitColliders.Length; i++)
- {
- if(hitColliders[i].GetComponent<Wall>())
- {
- hitColliders[i].GetComponent<Wall>().Dead();
- }
- if(hitColliders[i].CompareTag("CanBeRigidbody"))
- {
- if(!hitColliders[i].rigidbody)
- {
- hitColliders[i].gameObject.AddComponent<Rigidbody>();
- }
- hitColliders[i].rigidbody.AddExplosionForce(Force, transform.position, Radius, 3.0F);
- }
- }
- Destroy(gameObject,0.2f);
- }
- void OnDrawGizmos()
- {
- Gizmos.color = Color.red;
- Gizmos.DrawWireSphere(transform.position,Radius);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement