Rigidbody2D doesn't move

I’m having an issue with the use of Rigidbody2D. I have a Rigidbody2D attached to my player and sometimes the player don’t move even if it should. Here’s a gif to show the problem.


Note that since the red square touch the ground I always press a key. One can see that the square is blocked for no reason at the limit of the first tile in the right. I don’t achieve to locate the problem source.

Here’s the movement code:

protected void Move(float x, bool jump)
        Vector3 targetVelocity = new Vector3(x, rd.velocity.y);
        rd.velocity = Vector3.SmoothDamp(rd.velocity, targetVelocity, ref curVelocity, movementSmoothing);

        if (jump)
            this.jump = false;
            if (onGround)
                rd.AddForce(new Vector2(0, jumpForce));
                onGround = false;
            else if (airJump)
                rd.AddForce(new Vector2(0, jumpForce));

curVelocity is initialized to Vector3.zero and this.jump is a property used to avoid some issues with update methods. There is a TilemapCollider2D attached to the tilemap of the white squares. What can be the origin of the problem and how can I solve it please ?

Edit: I found the problem but I don’t see how to solve it. I draw the contacts points of the Rigidbody2D and here is what I have:

For me it’s non-sense. First I didn’t thought that contact between Rigidbody2D and colliders occur when they are not against each other. Aside from this, the 2 right contact points should not exist and I don’t understand why the do.

Hi! why don’t you use the “Box Radius” property on your Box Collider, this way corers will no longer be a square and with a rounded corner, a tiny gap will not be a problem…

Hope this Helps!

Use a composite collider on your tile map. This will combine the tiles into large surfaces, preventing the character getting stuck between tiles.

Thanks it solve my problem. But I still not understand why these colider points exists as there is no collider at their position. If you or anyone else have explaination for that I’ll be glad to take it.