# Unity: OnCollisionEnter not called

I created a sphere object, added a rigidbody component (no kinematics) and attached a script to it like this:

function Update () {
}

function OnCollisionEnter(collision : Collision) {
Debug.Log("OnCollisionEnter");
}


I then created a cube under the ball, added a box collider component with no trigger of course.

Then, when I run the game, the ball falls down onto the cube, but nothing happens. The OnCollisionEnter function isn't called.

What should I do?

• Has the ball a collider attached too? – Heisenbug Mar 10 '13 at 12:27

I move the comment here, so we can eventually close the post.

Remember that both GameObject MUST have a Collider attached in order the OnCollisionEnter to be called.

As side notes:

• A MeshCollider cannot collide with another MeshCollider.
• Even if your colliders as marked as trigger, at least one of the 2 GameObject involved must have a RigidBody attached.
• Collision between GameObject can be selective enabled depending on the layer the GameObject's belong to. Have a look at Layer-Based Collision Detection.
• well, in docs, it says, both of the objects must be rigidbody or collider. In my case, one of them is rigidbody and the other one is collider...and it doesn't works... – Nami WANG Mar 10 '13 at 14:47
• No, it doesn't says "or". Doc says: "When a collision between two Colliders occurs and if at least one of them has a Rigidbody attached, three collision messages are sent out to the objects attached to them." So both must have a collider and at least one of 2 a RigidBody attached. – Heisenbug Mar 10 '13 at 14:50
• Good bullet points to add: Each object's respective layer must be enabled for collision in the PhysicsManager, and the ability of an object to collide with another is further defined by the collision action matrix at the bottom of this page: docs.unity3d.com/Documentation/Components/… – michael.bartnett Mar 10 '13 at 18:20
• @michael.bartnett: good point. I've add it thanks. – Heisenbug Mar 10 '13 at 19:57