You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			24 lines
		
	
	
		
			736 B
		
	
	
	
		
			C#
		
	
			
		
		
	
	
			24 lines
		
	
	
		
			736 B
		
	
	
	
		
			C#
		
	
using UnityEngine;
 | 
						|
 | 
						|
namespace Autohand.Demo{
 | 
						|
    public class ExplosionSource : MonoBehaviour{
 | 
						|
        public float radius = 1;
 | 
						|
        public float force = 10;
 | 
						|
 | 
						|
        public void Explode(bool destroy) {
 | 
						|
            var hits = Physics.OverlapSphere(transform.position, radius);
 | 
						|
            foreach(var hit in hits) {
 | 
						|
                var rb = hit.GetComponent<Rigidbody>();
 | 
						|
                if(rb != null)
 | 
						|
                    rb.AddExplosionForce(force, transform.position, radius);
 | 
						|
            }
 | 
						|
            if(destroy)
 | 
						|
                Destroy(gameObject);
 | 
						|
        }
 | 
						|
 | 
						|
        private void OnDrawGizmosSelected() {
 | 
						|
            Gizmos.color = Color.red;
 | 
						|
            Gizmos.DrawWireSphere(transform.position, radius);
 | 
						|
        }
 | 
						|
    }
 | 
						|
} |