Trouble with Collision

I have a move script for my player and it works fine except when I’m going too fast (which really isn’t that fast) I got through objects. I’m using a rigidbody and I’ve tried all of the different collision detection modes and nothing has worked. Does anyone know if I should I use a different physics component/reference the physics component in my move script?

The script:

{

    Animator animator;
    Vector2 input;
    Rigidbody rb;

    public float speed = 10f;

    // Start is called before the first frame update
    void Start()
    {
        animator = GetComponent<Animator>();
        rb = GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        //movement

        //sprint
        if (Input.GetKey(KeyCode.LeftShift) && Input.GetKey("w"))
        {
            transform.position += transform.TransformDirection(Vector3.forward) * Time.deltaTime * speed * 2.5f;
        }
        //walk forward
        else if (Input.GetKey("w") && !Input.GetKey(KeyCode.LeftShift))
        {
            transform.position += transform.TransformDirection(Vector3.forward) * Time.deltaTime * speed;
        }

        //walk backward
        if (Input.GetKey("s"))
        {
            transform.position -= transform.TransformDirection(Vector3.forward * Time.deltaTime) * speed;
        }

        if (Input.GetKey("a"))
        {
            transform.position += transform.TransformDirection(Vector3.left * Time.deltaTime) * speed;
        }

        if (Input.GetKey("d"))
        {
            transform.position -= transform.TransformDirection(Vector3.left * Time.deltaTime) * speed;
        }

        //animation
        input.x = Input.GetAxis("Horizontal");
        input.y = Input.GetAxis("Vertical");

        animator.SetFloat("InputX", input.x);
        animator.SetFloat("InputY", input.y);
    }
}

Various problems. First, don’t modify the transform when you’re using a rigidbody. If you plan to use that kind of approach (as opposed to adding forces) you should use Rigidbody.MovePosition. Otherwise, manually adjusting the transform causes the object not to behave properly with the physics system.

If you’re still going through objects, you should just search for “unity fast object goes through wall”, or similar searches. This is a common thing that comes up all the time.