Camera Clips though Walls

I am trying to convert this script from using Transform to Rigidbody so that the camera can collide with walls, but everything I do does’int work. Can someone help me?

    zoom += Input.GetAxis("Mouse ScrollWheel") * zoomSpeed;
    if (zoom > zoomMin)
               zoom = zoomMin;
    if (zoom < zoomMax)
               zoom = zoomMax;
    playerCamera.transform.localPosition = new Vector3(0, 0, zoom);

OK so first of all you got the > and < mixed up just change them to opposite and also if nothing happens at all when you rotate the mouse wheel then i would check the input manager or the input code also i advise that you multiply the zoom by zoomSpeed when applying the zoom not when taking the input so instead of doing it here: ‘zoom += Input.GetAxis(“Mouse ScrollWheel”) * zoomSpeed;’ Do it here: ‘playerCamera.transform.localPosition = new Vector3(0, 0, zoom *x zoomSpeed);’

if that didn’t solve your problem then you should describe the problem more in detail instead of just saying everything I do doesn’t work.