what object hit me? easy rigidbody question

trying to print the name of an object that collides with a rigid body. There's a lack of clear simple examples of this in the scripting documentation. There's something wrong with the code below but I can't tell what..

I get error messege "An instance of type 'UnityEngine.Collision' is required to access non static member 'gameObject'." Being a newbie i don't understand the error message. Can you hep.

function OnCollisionEnter(collision : Collision) {
        var whohitme = Collision.gameObject ; 
        print ("i was hit by"+whohitme);
}

Here's another version I'm trying but this also does not work. This is a simple one I'm sure.

function OnCollisionEnter(collision : Collision) {  
        var whohitme =Collision.collider ;
        print ("i was hit by"+whohitme);

}

changed your code to work

you were using the class name instead of the variable name to get the gameobject

also , swapped it to print out the name of the gameobject, not the gameobject itself

function OnCollisionEnter(collision : Collision)
{
    var whohitme = collision.gameObject;
    print ("i was hit by"+whohitme.name);
}