Help With RigidBody [Solved]

Hello, I have been using Unity’s First Person Controller to move my player. But, when I saw a video explaining why you shouldn’t (nothing bad about it, just that you should understand the code before using it) I started making my own. Here is the code:-
using UnityEngine;
using System.Collections;

public class TransformRotate : MonoBehaviour
{
    public float moveSpeed = 5f;
    public float turnSpeed = 50f;
    
    
    void Update ()
    {
        if(Input.GetKey(KeyCode.UpArrow) && !Input.GetKey(KeyCode.W))
            transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
        
        if(Input.GetKey(KeyCode.DownArrow) && !Input.GetKey(KeyCode.S))
            transform.Translate(Vector3.back * moveSpeed * Time.deltaTime);
        
        if(Input.GetKey(KeyCode.LeftArrow) && !Input.GetKey(KeyCode.A))
            transform.Translate(-Vector3.right * moveSpeed * Time.deltaTime);
        
        if(Input.GetKey(KeyCode.RightArrow) && !Input.GetKey(KeyCode.D))
             transform.Translate(-Vector3.left * moveSpeed * Time.deltaTime);

        if(Input.GetKey(KeyCode.W))
            transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
        
        if(Input.GetKey(KeyCode.S))
            transform.Translate(Vector3.back * moveSpeed * Time.deltaTime);
        
        if(Input.GetKey(KeyCode.A))
            transform.Translate(-Vector3.right * moveSpeed * Time.deltaTime);
        
        if(Input.GetKey(KeyCode.D))
             transform.Translate(-Vector3.left * moveSpeed * Time.deltaTime);
    }
}

Due to removing all of the First Person Controller Functions except for MouseLook.cs I found out that gravity was not there. When I added the Mesh Collider and RigidBody it falls through the floor (Cubes). It all works except for the Gravity. I want it to fall and “Use Gravity” but I don’t want it to fall through objects.

Bringing it back to my question, how do I make it so it won’t fall through the floor?
Any answers are appreciated.

Rigidbody.addForce would work, checking for collisions yes. But the movement for the character is not well behaved, since the object would actually move for some time after u stoped applying force to it, making character movement not behaving as you would with. I never done it myself(since i at the moment use Character controller), but it seems to me that the best option would be rigidbody.velocity. But the again:

Try using rigidbody velocity, but dont change it for every time the key is pressed, but rather:

void Update()
{
if(Input.getKeyDown(Keycode.W))
   rigidbody.velocity += transform.forward *speed*Time.deltaTime;
if(Input.getKeyUp(Keycode.W))
   rigidbody.velocity -= transform.forward *speed*Time.deltaTime;
}

Edit: another thing worth checking: