MouseOrbit script help?

I have a script that allows the camera to zoom in/out and orbit the Third Person Controller, but the problem I have is that the camera orbits anytime the cursor moves. I would like it to stay put, and only be able to orbit when the middle mouse button is held.

At line 45 add this condition :

if(Input.GetMouseButtonDown(2){

}

and your code should be like :

if(Input.GetMouseButtonDown(2){
      x += Input.GetAxis("Mouse X") * xSpeed * distance * 0.02f;
      y -=  Input.GetAxis("Mouse Y") * ySpeed * 0.02f;
}

Note: it’s untested though.