Collision between two prefabs not being detected
I am trying to get collision detection between two prefabs, but nothing is happening.
void OnCollisionEnter(Collision col)
{
Debug.Log("Collided with something...");
if (col.gameObject.name == "Dorito(Clone)")
{
Debug.Log("Collided!");
Destroy(col.gameObject);
Destroy(gameObject);
}
}
neither of the Debug.Log points get triggered, and I don't know why. What have I done wrong?
Comment
make sure one of the collider is not trigger.
one of them must have rigidbody.
go to edit -> project settings -> physics and set sleep threshold to zero.
I've done that, but do the objects need box colliders? They both have RigidBody2Ds, but not box collider 2D.
Your answer
Follow this Question
Related Questions
On collision x or y 2d c# 1 Answer
Doodle Jump Game Platform Spawn Issue Unity2D 0 Answers
Can't make the player attack an enemy 0 Answers
Can't get object to destroy itself on collision. 0 Answers
How to show an object when collided with 0 Answers