✅ Unity: Issue with the Box Collider 2D and Layers.
Hi.
I need help with some collider situation I have. In words: It seems like the layer of the collider is ignored/mixed up when inheritance is involved.
In the following image, I'm trying to explain my problem:
Top left: This is my structure. The Crate sprite is attached to "Crate (2)". "Main" has a Box Collider 2D, on the layer "Player Ignored Collider" (top right image). "Smaller" has another Box Collider 2D, but is on the layer "Default" (top middle image). The "Table" (bottom right image) has a Box Collider 2D and is on the "Player Collider" layer.
Based on the collision matrix, I would expect my "Crate (2)" to fall partly through the table, but as you can see on the left image (which is the state reached once the game plays), it gets stopped by the collider on "Main" even if the matrix says it shouldn't.
Anyone can enlighten me?
8 Replies
Maybe the issue is actually the smaller collider? It's inside the player ignored collider, and player ignored collider is allowed to collide with "default"
So it having that collider inside it locks it in place
If I disable "Main", the expected collision happens. I feel like "Crate (2)" looks at every sub component that has a Collider associated, and applies all layers to all colliders.
What if you disable collision between default and player ignored collider in the matrix?
After asking 3 times (over two days, not as spam) someone in the Unity discord just figured it out. I was adjusting the collison matix of Physics, not Physics 2D . . .
Hahahahaha
*facepalm*
Oh well, at least it wasn't something weirder
I was really grasping at straws trying to see wtf could be wrong there
Yeah. I figured it was a me problem, but I didn't know why it was 😛
Thanks for looking into it too, it's much appreciated 😄