- Home /
Objects going partway through each other
Hello everyone. I've exported some building block shapes from Max and in Unity I've tried box and mesh colliders on the objects but they pass partway through each other when they collide, the collision is happening at the center of the mesh rather than the outside. The collider surrounds the mesh. A screenshot of what I mean can be found here.
could it simply be Edit -> Project Settings -> Physics -> note the various settings for penetration, solver etc.
If they're just box items (What it looks like), use the box collider for those, and not the mesh collider. $$anonymous$$ore accurate I've found.
Thanks Fattie. I even tried creating regular cubes and it was still happening so I had to drop the $$anonymous$$in penetration down to .00001 and put the iteration count at 10. Box colliders work ok for these shapes but I do have other shapes that will require mesh colliders.
Bear in $$anonymous$$d that $$anonymous$$eshColliders are subject to back face culling - that limits their use when not colliding with a first/3rd person character (i.e. enemy/enemy collision etc).
Answer by TheDavil86 · Jun 21, 2012 at 01:04 PM
Well I can say that if they're using mesh colliders and you have a rigid body component attached to them they will go through each other if "convex" is not checked in the mesh collider properties. But if you're using box colliders they should work as long as the boxes are set up right. Try recalculating normals maybe if none of that works.
Answer by WarmBiscuit · Sep 27, 2017 at 04:09 AM
I was having this same issue making a 2D game. So if anyone is having this problem in 2D, I've found one solution:
Go to Edit >> Project Settings >> Physics 2D >> Then change the "Position Iterations" from 3 to about 8. This ups the iterations that check the positions of things, like your player's movement.
I was moving my main player with rigidbody.transform.Translate((Vector3.right moveThrust) Time.deltaTime, Space.World); and my player would go halfway into walls as I moved him around. But upping the Position Iterations fixed that problem.
The downside to this, is that it makes your program more costly memory-wise. So it may not be the best way to fix the issue, but I couldn't find any other solution...