void Update()
    {
        //using input from the player on xbox controller, determine where to move the camera
        angleX += gameInputManager.getStick("RightStickY") * Time.deltaTime * verticalSpeed * -1;
        angleY += gameInputManager.getStick("RightStickX") * Time.deltaTime * verticalSpeed * -1;

        //using input from keyboard, determine where to move the camera
        if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
        {
            angleX += Input.GetAxis("Vertical") * Time.deltaTime * verticalSpeed * -1;
            angleY += Input.GetAxis("Horizontal") * Time.deltaTime * verticalSpeed * -1;
        }

        angleX  = Mathf.Clamp(angleX, minVerticalAngle, maxVerticalAngle);
        angleY %= 360;

        //calculate rotation of camera
        Quaternion xRotation = Quaternion.AngleAxis(angleX, new Vector3(1, 0, 0));
        Quaternion yRotation = Quaternion.AngleAxis(angleY, new Vector3(0, 1, 0));

        offset  = new Vector3(0, 0, 1);
        offset  = xRotation * offset;
        offset  = yRotation * offset;
        offset *= distance;

        //offset here becomes the result of offset plus the target position and target to camera
        //otherwise becomes the hit point if it has to avoid an obstacle
        offset = AddObstacleAvoidance(offset);

        switch (state)
        {
        case CamState.Follow:
            //if camera state is following, then set the new position and new rotation
            transform.position = offset;
            transform.rotation = Quaternion.LookRotation(target.position - transform.position, new Vector3(0, 1, 0));
            break;

        case CamState.Switch:
            //if camera state is switch, do nothing here because the SwitchTarget method will be called instead
            break;
        }
    }