damage reciever or laser script not working

hey guys whats wrong with this damage reciver it seems like it takes all damage at once
thanks


using UnityEngine;
using System.Collections;

public class Damagereciever : MonoBehaviour
{

public float Health = 100000.0f;
public Rigidbody deadReplacement;
//    public Rigidbody dead;

public void ApplyDamage(float damage)
{
    Health = -damage;

    if (Health <= 0.0)
        Detonation();
        return;
}

// Use this for initialization
void Start()
{

}

// Update is called once per frame
void Update()
{

}

public void Detonation()
{

    Destroy(gameObject);

    // If we have a dead barrel then replace ourselves with it!
    if (deadReplacement)
    {
        Rigidbody dead = (Rigidbody)Instantiate(deadReplacement, transform.position, transform.rotation);

        // For better effect we assign the same velocity to the exploded barrel
        dead.GetComponent<Rigidbody>().velocity = GetComponent<Rigidbody>().velocity;
        dead.angularVelocity = GetComponent<Rigidbody>().angularVelocity;
    }

}

}


here is my laserscript thats hitting the damage reciever


using UnityEngine;
using System.Collections;

public class PlasmaBeamWeaponRight : MonoBehaviour{

public GameObject plasmaBeam;
public float spawnTime = 5f;
//
public Transform target;
private bool CanSeeTarget;
public float BeamingRange = 500f;
//
private LineRenderer lineRenderer;
private float counter;
public float dist = 30f;
//
public Transform origin;
//
public float linrDrawSpeed = 6f;
public float damage = 10.0f;
RaycastHit hit;

// Use this for initialization
void Start()
{

}

// Update is called once per frame

void OnCollisionEnter(Collision col)
{

    col.gameObject.BroadcastMessage("ApplyDamage", damage = 100.0f);

}

void LateUpdate()
{

    target = GameObject.FindWithTag("Enemy").transform;
    origin = GameObject.FindWithTag("originR").transform;
    if (target != null)
        //
    lineRenderer = GetComponent<LineRenderer>();
    lineRenderer.SetPosition(0, origin.position);
    lineRenderer.SetWidth(.45f, 0.2f);

    dist = Vector3.Distance(origin.position, target.position);
    if (counter < dist)
    {
        counter += .1f / linrDrawSpeed;

        float x = Mathf.Lerp(0, dist, counter);
        dist = Vector3.Distance(origin.position, target.position);
        lineRenderer.SetPosition(0, origin.position);
        Vector3 pointA = origin.position;
        Vector3 pointB = target.position;

        Vector3 pointAlongLine = x * Vector3.Normalize(pointB - pointA) + pointA;

        lineRenderer.SetPosition(1, pointAlongLine);
        Vector3 fwd = transform.TransformDirection(Vector3.forward);
        if (Physics.Raycast(transform.position, fwd, 0))
            hit.transform.SendMessage("ApplyDamage", damage =10, SendMessageOptions.DontRequireReceiver); //Call the method Apply Damage in the gameobject that is hit
    }
}

}

Oh cmon… its pretty simple…

In ApplyDamage method, you are doing “Health = -damage” which implies health will be < 0 so detonation

Change it to “Health -= damage”

And on a side note, Dont use SendMessage/ Broadcast msg. They are all pretty slow!

Try to read up on “Events and Delegates” … They are powerful and efficient!