I was wondering if you could tag this script instead of having on collision.
var damage : float;
function OnCollisionEnter (other : Collision){
// Tell the object you hit that it was damaged
other.collider.gameObject.SendMessage("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);
}
If you want to check the hit object’s tag, do the following:
var damage : float;
function OnCollisionEnter (other : Collision){
if (other.transform.tag == "someTag"){
// Tell the object you hit that it was damaged
other.transform.SendMessage("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);
}
}
NOTE: Remember to place an ApplyDamage(damage: float) function in the object you want to damage.