Objects with collision detection passing through each other

I have a rigidbody with a box collider, and have been doing some testing with “Cube” primitives.

The object grows in size, and I resize the collider to match.

collider.center = collider.transform.InverseTransformPoint(renderer.bounds.center);
collider.size = collider.transform.InverseTransformDirection(renderer.bounds.size);

I am wondering if I am missing resizing something though…

In certain spots the box collider actually passes through cubes in the scene - and this is when I am looking at the box collider in scene view and can see it very obviously. Any ideas? Do I have to change something about the rigidbody when I resize the box collider? Are there moments when solid objects do pass through each other? Can objects pass through each other when going at sufficiently high speeds?

This may be complicated by the fact that I am trying to keep everything in a 2d plane. The rigidbody has rotation frozen, and at the end of FixedUpdate I have this line:

rigidbody.MovePosition(rigidbody.position - (rigidbody.position.z - currentZPosition) * Vector3.forward);

(To make sure the z position of the rigidbody never changes)[/code]

Any ideas? Thanks so much.

The behavior is quite strange. It seems that the “left” side of the object is the part that doesn’t go through things, while when the object grows, the “right” side can go through other objects.

For example, if I have a tiny cube, I can jump on it with the left side of the object, and the cube will support the object, nothing will move. (great!)
However, if I jump on it with the right side of the object, the right side will awkwardly slip through the cube, no matter what the dimensions of the cube. (so that my object falls completely through the cube)

It seems quite odd.