How would I restrict the cameras rotation in x and y in this script?
private void Update()
{
//Check if the left mouse button is held.
if(Input.GetMouseButton(0))
{
//Get the current mouse input.
yaw += Input.GetAxis("Mouse X") * mouseSensitivity;
pitch -= Input.GetAxis("Mouse Y") * mouseSensitivity;
}
//Get the current scroll input.
scroll -= Input.GetAxis("Mouse ScrollWheel") * scrollSensitivity;
scroll = Mathf.Clamp(scroll, minDistance, maxDistance);
//Update the rotation.
currentRotation = Vector3.SmoothDamp (currentRotation, new Vector3(pitch, yaw), ref rotationVelocity, 0.07f);
transform.eulerAngles = currentRotation;
//Update the position.
currentDistance = Mathf.SmoothDamp(currentDistance, scroll, ref distanceVelocity, 0.1f);
transform.position = targetTransform.position + transform.forward * -currentDistance;
}
thanks in advance