- Home /
Smoothing collisions with MeshColliders
Hey, I'm making a racing game, and I've built an arched bridge model for the player to cross a river with. Because it's a racing game, it's quite important that collisions are smooth, so I've also built a collision mesh, which is simplified, but which a much smoother curve. However, when I use this mesh as a MeshCollider, the car judders a lot when going over the bridge, and occasionally just stops moving for a few seconds. I can make it slightly better by checking the "Convex" option, but that seems to drastically simplify the mesh, to a point where it's much less smooth that I need it to be. My question is - is there a way I can keep the Mesh collisions smooth? I try to avoid using MeshColliders if I can, so I don't have much experience with them, but this seems a time that I can't avoid it. Can anyone else me work out how to use these correctly?
The left is the collision mesh, the right is the same mesh with "Convex" checked, and the bottom is the model (graphical only).
Hi there, although this comes late, and you've probly already found a solution for this, you could use a Cube Primitive. With the renderer turned off, you can scale it long and flat, to fit on top of that bridge.
If the collision must be within that bridges components, then you could switch out the $$anonymous$$esh collision with a Box Collider ins$$anonymous$$d, although it will take longer to shape it and you can only have one box collider within an object.
I'm not sure how that will help - the bridge is curved, so the box collider is of little use on its own. I did consider using a number of smaller box colliders, but discovered that would be even worse for my engine thanks to the collider tolerance levels. It works reasonably well as it is, though, so I think it's fine.
Check "S$$anonymous$$lth" project's tutorials. They put a pre-prepared mesh as a $$anonymous$$esh Collider, which takes less place and less procedural.
They have a mesh prepared to be used as a collider. Less polygon, textureless. Realistic collision, better performance.
Alternatively you can use capsule collider as your collider mesh but you will have to play with settings a lot. You can use three plane colliders too, two of them being slopes and one of them for flat part of the bridge .