Help With Collison Detection On Unity 3. function ONENTERCOLLISION not working?

Sorry if this seems to be a newbie question. However i seems to have problems detecting collision between my player and the gameObject i want to detect. Am i writing it wrong somehow?

function OnCollisionEnter(collision : Collision)
{
Debug.Log(" i got u");

if(collision.gameObject.Find(“CarrotType1(Clone)”) getNos == 1)
{
Debug.Log(“hello”);
//Destroy(targets);
}

if(collision.gameObject.Find(“CarrotType2(Clone)”) getNos == 2)
{
Debug.Log(“hello”);
//Destroy(targetz);
}
}

it does not even output the “I got you” message in the Debug. Thanks in advance for any suggestions that i might be doing it wrong. :slight_smile:

Did you put the script on the gameobject? If you did, did you put the script on the gameobject with the collider?

Yeps i did, i added the script on the player itself. with character controller. The carrot i am trying to collide with have a rigid body and a box collider attached to it. maybe i could upload the whole project?

i been asking around in another forum somehow, no one could answer me. );

The thing is, when i redo the project from scratch, it works fine. for one time… after i tried building the project and running it, or closing it and trying it again. it doesnt work anymore.

i don’t seems to find any problems with my code, although. being a newbie to scripting. =/ i cant really say. haha!

i was hoping if anyone could point me to the right direction. (;
Whether is it a bug with unity 3, or its just a problem with my script. D:

420666–14599–$PaperTrails_Collectible_Revision_3.zip (1.38 MB)

The character controller does not count as a collider. Put the collision script on your actual cube.

wow. thanks! it works like a charm. :wink: thanks alot for that suggestion. I din realize that character controller aint counted as one.

thanks alot!! ;D

I didn’t know either :smile:.