collisions not working

my scene contains 2 boxes and a floor.

my character can stand on the floor and boxes but if i run at the side of the boxes the character goes through.

im not sure what im doing wrong.

private void move2()
{

   // Debug.Log("move2 called");
    if (Input.GetKey(KeyCode.W))
        rb.MovePosition(transform.position + transform.forward * speed * Time.deltaTime);
       
    if (Input.GetKey(KeyCode.S))
        rb.MovePosition(transform.position - transform.forward * speed * Time.deltaTime);
   

    if (Input.GetKey(KeyCode.A))
        rb.MovePosition(transform.position - transform.right * speed * Time.deltaTime);
   
    if (Input.GetKey(KeyCode.D))
        rb.MovePosition(transform.position + transform.right * speed * Time.deltaTime);
    

    if (Input.GetKeyDown("space"))
        jump();
},i don't understand why my player doesn't fall through the floor but can run through walls.

my scene contains a floor and 2 boxes, i can stand on the boxes and the floor but if i try walking into the boxes my character goes strait through.

i was originally using transform.translate but a quick google search made me try rb.moveposition instead
it works the same except i still have the same problem. its obviously colliding because it wont fall through the floor but i have no idea why the walls dont stop it.

private void move2()
{

   // Debug.Log("move2 called");
    if (Input.GetKey(KeyCode.W))
        rb.MovePosition(transform.position + transform.forward * speed * Time.deltaTime);
       
    if (Input.GetKey(KeyCode.S))
        rb.MovePosition(transform.position - transform.forward * speed * Time.deltaTime);
   

    if (Input.GetKey(KeyCode.A))
        rb.MovePosition(transform.position - transform.right * speed * Time.deltaTime);
   
    if (Input.GetKey(KeyCode.D))
        rb.MovePosition(transform.position + transform.right * speed * Time.deltaTime);
    

    if (Input.GetKeyDown("space"))
        jump();

what am i doing wrong

I’m not pro but apparently sometimes the update function goes quicker and it goes through the thing. Maybe make the collier bigger? or add a raycast? or try layer or tag?