[SOLVED]Why is this scripts output so choppy/glitchy?

[UPDATE]So the following script basically is not smooth, and I know there are ways to fix this but I am not entirely sure how…

(end of update)

I am trying to make a camera script that will move the camera horizontally with the mouse while the middle button is being held down, meaning forward left, right, back, and diagonal, but not up and down; What happens is that it works, but is choppy. How can I fix this?
Btw, it has to be attached to the camera to work:
movecamera.js:

 #pragma strict
 
 //NOTE: THIS SCRIPT HAS TO BE ATTACHED TO THE CAMERA TO WORK!
 
 function Update () {
 
 
 var flySpeed = 1;
 if(Input.GetMouseButton(2)){//For middle click
   
   if(Input.GetAxis("Mouse X")<0){//Left
       transform.Translate(Vector3.left * flySpeed);
   
       }
   if(Input.GetAxis("Mouse X")>0){//Right
   transform.Translate(Vector3.right * flySpeed);
 
   }
   if(Input.GetAxis("Mouse Y")>0){//Forward
   transform.Translate(Vector3.forward * flySpeed);
   
   }
   if(Input.GetAxis("Mouse Y")<0){//backward
   transform.Translate(Vector3.back * flySpeed);
   
   }
   
   }
   
  }

It’s choppy because you always move the same distance every frame.

Vector3.left * flySpeed

I don’t really know JS, so you will have to write the code yourself, but here’s what you should do.

  1. save the mouse position in a var (lastMousePosition) as soon as the button is pushed
  2. Next frame, if the button is still held down, take the current position and subtract lastMousePosition from it, store it in mouseDistance
  3. If the mouse button is let go, set LastMousePosition to Vector3.zero

Your new Translate() functions should look like this:

transform.Translate(Vector3.left * flySpeed * MouseDistance);

I solved the problem by basically doing what MonkeyHood had said, only by tracking the cameras position and using division. Thanks!