Help with simple collision problem.

Ok I know this is probably a simple solution to this. And I tried to solved myself.. But I need some help before my head explodes, or I have a stroke. I more of a graphics guy....

I working on very simple collisons. Basically I'm using the "First Person Controller" for the player I have added a simple cube(From Unity). I added Rigidbody to the cube. Basically I am trying to get it when so that when the player collides with the box. A message would display in the debug log.

I have written this script (javascript) and added it to the cube.


function OnCollisionEnter(collision:Collision){ 
    if (collision.gameObject.tag == "Player")    
        print ("yay it works"); 

I get no errors, but I also get no display in the console/debug log. So basically nothing is happening. Is their something wrong with the code? Can I get some help please?

You should probably verify that your player object has a collider whose configuration allows collision detection with the collider associated with your cube. Search for the "collision action matrix" (in the middle of the page) in the link below :

try using Debug.Log("yay") instead?

Make sure your player has a collider, and that the Is Trigger checkbox on the collider is unchecked. Also make sure that the rigidbody attached to your cube is not kinematic (i.e. that Is Kinematic is unchecked).

Then try changing your code to the following:

function OnCollisionEnter(collision:Collision){
    Debug.Log("Collided with: " + collision.gameObject.tag);

If everything is working right, you should see the tag value of any object that collides with the cube printed out to the console window.

Yep I figured it out I need to add a box collider, thanks for the help everyone... For some reason I thought a Character Controller was enough.