I am working on a movement code using the left and right keys, and the function rigidbody.MovePosition. When the player collides with walls it at first stops, but then if I hold down the key too long it will fall through the floor or walls eventually. The walls and floor have a box collider and the player has a rigidbody with default settings
function Update () {
if (Input.GetKey ("left"))
rigidbody.MovePosition(rigidbody.position + Vector3.left * 5 *Time.deltaTime);;
if (Input.GetKey ("right"))
rigidbody.MovePosition(rigidbody.position + Vector3.right *5 *Time.deltaTime`
Well moving objects can be done in multiple ways. Does your code depend on you using MovePosition? If not, just change to rigidbody.AddRelativeForce cause using forces provides better physics simulation. Read [this][1] [1]: http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.MovePosition.html
– ProbePLayer