OnCollisionEnter not working

I’m having some issues with a certain use case when two objects touch on screen, but do not “collide”.

The scenario is, that the bottom of the screen has shapes. When i click on the shape and drag, it generates a new shape and follows the mouse cursor, while following the mouse, the rigidbody is set to kinematic. When the shape is let go, i turn on gravity to make it drop to the bottom of the screen hitting a floor surface. When it reaches resting point, i turn it back to kinematic so that it stays in that position.

The problem arises when i create another object and try to drag it into the object on the floor. For some reason it doesn’t detect collisions between these two objects. However. If i drag two objects simultaneously and make them touch their OnCollisionEnter scripts get fired.

Is there a limitation i am overlooking? Can two kinematic objects not collide?

Cheers

make sure you’re spelling it right and case sensitive (OnCollisionEnter, OnTriggerEnter), spelling it wrong will not cause an error so you won’t know.

From http://unity3d.com/support/documentation/ScriptReference/Collider.OnCollisionEnter.html “Note that collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached.” You could maybe use OnTriggerEnter instead.

void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag != “Enemy” && col.isTrigger != true) { Destroy(gameObject); } }

you have to write Collision2D not Collider2D … :slight_smile: