# Is it possible to make a Mesh Collider thicker?

I’m having problem of moving rigidbody objects going through mesh terrain, even with ‘`Continous Collision Detection`’ is enabled. A good solution proposed here is to make the ground collider thicker.

Now, since I am using a mesh collider for the ground, is there a way to make the mesh collider thicker?

One way is to make a new mesh using the old mesh. Here’s an example that uses the normal for each vertex, although it’s far from perfect - mostly because the higher the perturbation, the smoother the mesh will get, and it doesn’t handle seams to smoothing groups well. But, it’s not a bad starting point.

``````using UnityEngine;
using System.Collections;

public class Test : MonoBehaviour {

void Awake()
{
MeshCollider mc = GetComponent<MeshCollider>();
mc.sharedMesh = ThickerMeshUsingNormals( mc.sharedMesh, 1.0f );
}
// Function only cares about verts, tris and normals...
// Which should be fine because we're only messing with
// this stuff for collision
Mesh ThickerMeshUsingNormals( Mesh m, float fPerturb )
{
// USE THE NORMALS TO INFLATE THE MESH
// We're going to store the new results as a new
// verts list.
Vector3 [] rv3OrigVerts = m.vertices;
Vector3 [] rv3Norms = m.normals;

int nVertCt = rv3OrigVerts.Length;
Vector3 [] rv3NewVerts = new Vector3[ nVertCt ];
for( int i = 0; i < nVertCt; ++i )
rv3NewVerts <em>= rv3OrigVerts <em>+ rv3Norms _* fPerturb;_</em></em>
``````

* // CREATE AND RETURN THE MESH*
* Mesh mRet = new Mesh();*
* mRet.vertices = rv3NewVerts;*
* mRet.triangles = m.triangles;*
* // A cheap thing to do would be to just transfer the*
* // old normals, although that wouldn’t be right (both*
* // in spirit, and mathematically).*
* //*
* // mRet.normals = rv3Norms;*
* mRet.RecalculateNormals();*

* return mRet;*
* }*

}

how fast is the object moving to the ground ? and have u changed or altered game time in anyway ? is it anywhere on the ground or some areas where there is deformation ?
also have u tried DontGoThroughThings