- Home /
My 2 Objescts doesnt collide
Hey, I've two gameobejects(a duck and a knife) and each of them has a rigidbody and a box colider.It will be a 2D game for android. I looked on other questions and tried many different stuff but none of them worked.
The Following code: void OnTriggerEnter(Collider other) {
Debug.Log("Bullet hit23!");
}
I hope somebody can help me :=)
edit:
I addded a is trigger, and I noticed that only a duck can collide with a duck and not with the knife
interessting. I did but i seems that only a duck can collide with a duck. I did the box collider bigger and now ducks colliding in each other but the knife doest get collided
Answer by r59q · Aug 09, 2020 at 11:18 PM
Triggers can't collide. Use BoxCollider2D and OnCollisionEnter2D() instead.
If two BoxCollider2D intersects, OnCollisionEnter2D will be called. If, however one of them has the 'trigger' checkbox ticked, they won't.
void OnCollisionEnter2D(Collision2D collision)
{
Debug.Log("Hit");
}
Good luck!
Your answer
Follow this Question
Related Questions
Collider2D.IsTouchingLayers() delayed reaction 1 Answer
Collider2D/RigidBody2D not working 1 Answer
Continuously moving rigidbody 2 Answers