Clamping RotateAround()

Hi all,
I know that this question has been asked many of times, but I cannot find a solution which works for my code.

I am trying to get the camera to rotate vertically around my player object using the RotateAround function, and I also have the script rotate the player horizontally as well.
Here is my code:

public class MouseLook : MonoBehaviour {

    public GameObject target;
    public float xSensitivity;
    public float ySensitivity;
    public float minAngle = 30.0f;
    public float maxAngle = 80.0f;

    Transform tTransform;    //Transform reference for the camera's target
    Transform mTransform;    //Transform of this object
    string tName;

    // Use this for initialization
    void Start () {
        tName = target.name;
        tTransform = target.transform;
        mTransform = GetComponent<Transform> ();

        mTransform.SetParent (tTransform);
    }
   
    // Update is called once per frame
    void Update () {
        //Locking the cursor to the middle of the screen, and hiding it
        Cursor.lockState = CursorLockMode.Locked;
        //Cursor.visible = false;

        //Rotating the camera's target
        float h = Input.GetAxis(tName + "Mouse X") * xSensitivity * Time.deltaTime;
        float v = Input.GetAxis(tName + "Mouse Y") * ySensitivity * Time.deltaTime;
       
        tTransform.Rotate (tTransform.up * h);
        mTransform.RotateAround (tTransform.position, mTransform.right, -v);
    }
}

I would like to know if anybody has any idea on how I’d be able to clamp the rotation of the camera using a min and max values.

Bump

Did you find a solution?

Instead of using RotateAround, set exact rotation value for the Transform using the angle. You might have to create a new Quaternion from axis angles or something, i think the error log told exactly what function to call as there was even some old way that got deprecated.