Enemy Damage (431944)

I have and enemy set up with an enemy health script, like this

var health = 1.0;
var hitsound : AudioClip;

function OnTriggerEnter (hit : Collider) {
	if (hit.gameObject.tag == "cube") {
		
		health -= 1;
		
		if (hitsound)
			AudioSource.PlayClipAtPoint(hitsound, transform.position);	
	}
}

function Update () {
	if (health == 0) {
		Destroy (gameObject);
		
		if (hitsound)
			AudioSource.PlayClipAtPoint(hitsound, transform.position);	
	}
}

and I need to have an explosion cause damage to the enemy. I would like to keep my current system, unless I absolutely cant achieve what I need with the way I have it set up. I am using the detonator package, with the chunks pre made explosion, and I need the explosion to cause damage, not the projectile (I’m using a grenade, and so that wont work that way)

use sendmessage in the explosion script. if the enemy is within the explosion radius then call sendmessage to apply the damage to whatever it is that you hit

How would I do this? What you said is a little confusing sounding

there are a few ways. the way i learned is to give the explosion a radius and a damage variable. when u instantiate it when your weapon hits something, check for all the colliders that were hit. then do a collider.sendmesageupwards call with the damage.

in the send message line, you need to put the function you want to call, followed by your damage variable. for example the player will have an function named Damage, which gets passed in an integer. in the sendmessage you would put collider.SendMessageUpwards(“Damage”, damage variable)