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);
}