- Home /
Trigger problem with overlapping boxCollider2D
I have a ball that’s hitting aligned bricks. Each brick has a boxCollider2D (in red in the first picture). If the ball hits a brick, using it's OnCollisionEnter2D handler, I can do some logic to the concerned brick. It works fine except when the hit is between 2 bricks, the bounce becomes unpredictable. It’s a Unity limitation (the ghost vertice problem) where the physic engine does not see the aligned bricks as a uniform surface. To avoid this, I set the red boxCollider2D to isTrigger=true and added a large collider (in green in the 2nd picture) so now the bounce is always fine but the OnTriggerEnter2D event is not always fired. Same thing with an exaggerated smaller collider (3rd picture). If I remove the large collider, the OnTriggerEnter2D event is never missed. I have set the bricks on a different collision layer than the big collider object and set not to collide each other in the collision matrix. No joy. Is it possible to have overlapping boxCollider2Ds that can catch collisions and triggers?
Your answer
Follow this Question
Related Questions
Platformer2D Player sticks to platform corners 0 Answers
BoxCollider2D + Edge radius + use auto mass 1 Answer
OnTriggers hit wrong 1 Answer