[3D] Character stuck between cubes.

My character get’s stuck between cubes (that i use as platforms) when walking, just at the edge between them and the both cubes are side by side with no space in between.

My character has a rigidbody with freezed rotation axis.

I tried box collider, sphere collider, capsule collider… none of them seems to be the problem. I also tried adding a sphere colliders at the bottom of the box collider but nothing.

Cubes are box colliders with scale of (20, 1, 20).

EDIT - Here is a screenshot, there are the two cubes side by side and the capsule collider stuck between them:
72673-problem.png

EDIT2 - Rigidbody

72676-problem2.png

Edit3 - Movement Script:

Vector3 dir = movementJoystick.inputDirection;
Vector3 forward = mainCamera.transform.TransformDirection (Vector3.forward);
forward.y = 0;
forward = forward.normalized;
Vector3 right = new Vector3 (forward.z, 0, -forward.x);
float h = dir.x;
float v = dir.z;
dir = h * right + v * forward;
body.position += dir * (Time.deltaTime * walkSpeed);

SOLVED: It had to do with OnCollisionEnter and OnCollisionExit. I was using a bool of grounded to know if the character was or not. Seems traspassing the edge of the collider called the function making grounded go false.

Then i have specified that if my character is not grounded he won’t be able to move. So that whas the problem.

So from now on i will use raycasting. Thanks to everyone that helped me!

Try using one big box collider for both cubes. Sometimes(if your object too small) unity can’t response fast enough to detect collision. You can also change that response time( time settings / Fixed Timestep). Also change your rigidbody component’s Collision Detection as Continuous Dynamic. And make sure your collider component’s “Is Trigger” option unchecked. If problem still exist check your physics settings (Layer Collision Matrix). These are the basic rules that you should look first when your colliders act weird. But in your case you should also check your script again. Disable the script and try again. Your script could be the problem.

Have you tried making your collision detection continuous or continuous dynamic? It is normally used for detection collisions between fast moving objects like bullets, but it could do the trick for you.

Okey i feel ashamed, it had to be with my grounded collision script.

On leaving a collider it declared grounded as false and i have defined that something that is not grounded can’t move at all.

So when the character was reaching the edge of the first cube it goes directly to grounded = false and then is unable to recognize fast enough the second cube for getting the grounded = true.