OnCollisionEnter not working

Hey

I am trying to make a simple collision detection scprit. I have tried it several times in different projects, and it seems to not work. It is written in C#, i have tried using this in various formats and it still doesnt work.

Can someone tell me whats wrong? or is it something that i must put onto my game objects? they all have box collides already.

 function OnCollisionEnter(theCollision : Collision){

     if(theCollision.gameObject.tag == "Player"){
      Debug.Log("Hit the Good_Fruit");
      
     }
     else Debug.Log("no collision yet !!!@@#@!$ ");
     } 

Thanks

Do you have a collider? If you dont have a box/sphere/mesh collider then the script wont work I guess.
Here at the link below, u can see, I made a 3d model in blender called chair. I also made a model called collider and added mesh collier component to it.
THen i added both of them to an empty object called officeChair,

I too faced a similar problem, it worked out this way

Hope this helps

This happens very rarely but sometimes, for some reason unity stops synchronizing with mono editor and even though you update the script it does not follow new lines of code, instead it keeps compiling lines that are not even there anymore. Just happened to me, even though I tried to get collisions it would not work but then I realized it was printing some debug message from a print() statement that I put on line 83, however I had deleted that print() function before I started to run the game and saved the script.