explosion doing damage

Hi thats modified version of a script from the fps tutorial.
Attach it to a particle system, spawn it when an object destoys itself ( rocket hit wall / barrel get shot )
It will do damage to the sourounding ( via the message apply damage)

But the Problem: It only checks for riggid bodies, it doesn’t work on the fps controler or a character controler. Any Ideas ???

var explosionRadius = 5.0;
var explosionPower = 10.0;
var explosionDamage = 100.0;
var explosionTime = 1.0;

var sound : AudioClip;
var soundVolume : float = 2.0;

function Start () {
	
	var explosionPosition = transform.position;
	var colliders : Collider[] = Physics.OverlapSphere (explosionPosition, explosionRadius);
	
	for (var hit in colliders) {
		if (!hit)
			continue;
		
		if (hit.rigidbody) {
			hit.rigidbody.AddExplosionForce(explosionPower, explosionPosition, explosionRadius, 3.0);
						
			var closestPoint = hit.rigidbody.ClosestPointOnBounds(explosionPosition);
			var distance = Vector3.Distance(closestPoint, explosionPosition);

			// The hit points we apply fall decrease with distance from the hit point
    	    var hitPoints = 1.0 - Mathf.Clamp01(distance / explosionRadius);
			hitPoints *= explosionDamage;

			// Tell the rigidbody or any other script attached to the hit object 
			// how much damage is to be applied!
			hit.rigidbody.SendMessageUpwards("ApplyDamage", hitPoints, SendMessageOptions.DontRequireReceiver);
		}
	}

if (sound)											// ansonsten gehts hier weiter
		AudioSource.PlayClipAtPoint(sound, transform.position, soundVolume);

    // stop emitting ?
    if (particleEmitter) {
        particleEmitter.emit = true;
		yield WaitForSeconds(0.5);
		particleEmitter.emit = false;
    }
        // destroy the explosion
	Destroy (gameObject, explosionTime);

Read through the Reference on CharacterController – that guy is ignored by the physics engine. It does, however, have a collider so you could do something like

if(hit.gameObject.tag == "Player")
{
   // apply damage, again noting that AddExplosionForce will
   // have no effect on the player transform because of
   // the CharacterController behavior(s)
}

Thank You, now it works with everything which can receive ApplyDamage :smile:

	var explosionPosition = transform.position;
	var colliders : Collider[] = Physics.OverlapSphere(explosionPosition,explosionRadius);
	for (var hit in colliders) {
		
		var closestPoint = hit.ClosestPointOnBounds(explosionPosition);
		var distance = Vector3.Distance(closestPoint, explosionPosition);

		
		var hitPoints = 1.0 - Mathf.Clamp01(distance / explosionRadius);
		hitPoints *= explosionDamage;

		
		hit.SendMessageUpwards("ApplyDamage", hitPoints, SendMessageOptions.DontRequireReceiver);
	}

(taken mostly from the tut)