Rigid Body going through walls

Hi,
I made my character using a RigidBody and a Capsule Collider, but when testing it sometimes goes through “wall” colliders, when on the editor it rarely occurs but on Android it is almost like if there was no colliders at all.

My movement code is:

player.MovePosition(player.position + player.transform.forward * movSpeed * Time.deltaTime);

Where:
player = character Rigid Body
movSpeed = float of how fast it should move

I tried to do the following to, but with no success:

if (!Physics.Raycast(new Ray((player.transform.position + new Vector3(0, 1.5f, 0)), player.transform.forward + new Vector3(0, 1.5f, 0)), movSpeed * Time.deltaTime))
	player.MovePosition(player.position + player.transform.forward * movSpeed * Time.deltaTime);

What can I do? Thanks in advance.

Do you have this code in Update or in FixedUpdate? Physics related movement has to be in FixedUpdate. Also the direction of your ray doesn’t make any sense. It goes forward and upward but more up than forward.

There is this little helper script which is ment to be attached to a Rigidbody to prevent it from going through obstacles.