SendMessage not doing what it should

Hi,

I have been trying to make some code so that when you collide with an enemy, text pops up saying “Dead”
The enemy class finds that you’re dead and then is supposed to send a message to the text class (called Dead) to run its function (called Death) I have no errors and it prints out “collide” when I hit an object. It doesn’t have an error when I collide, it just doesn’t send the message.

Enemy code:

var Health = 100;
var Player : GameObject;

function Update ()
{
    transform.Translate(0, 0, Time.deltaTime);
    if(Health <= 0)
    {
    Dead();
    }
}

function ApplyDamage (TheDamage : int)
{
    Health -= TheDamage;
}
function Dead()
{
    Destroy (gameObject);
}

function OnCollisionEnter (col : Collision)
{
    if(col.gameObject.name == "Player")
    {
            Debug.Log ("colision");
        gameObject.SendMessage("Death");
        //Destroy (col.gameObject);
    }
    else if(col.gameObject.name == "Ball")
    {
        Destroy (gameObject);
    }
}

Death code:

#pragma strict

function Start () {

}

function Update () {

}
function Death ()
{
    Debug.Log ("Dead");
    GetComponent(MeshRenderer).enabled = true;
   
}

Any and all help is appreciated.

I think it should be col.gameobject.sendmessage.

Use GetComponent or delegates and events. or Event Actions. More reliable and you don’t have to use a string.

how would I use delegates/events?

The first step is searching the Unity documentation and C# documentation for “delegates” and “events”. Then, when you have a specific problem with one of them, coming back here and asking about it.