Campanu
1
public float sensivity = 7f;
public float mouseMax = 50f;
public float mouseMin = -50f;
void Update () {
// look up & down
float mouseY = Input.GetAxis ("Mouse Y");
mouseY = Mathf.Clamp (mouseY, mouseMin, mouseMax);
transform.Rotate (mouseY * sensivity, 0f, 0f);
}
I did some research:
your case:
void Update () {
// look up & down
float mouseY = Input.GetAxis ("Mouse Y");
transform.Rotate (mouseY * sensivity, 0f, 0f); // calculate new rotation
Vector3 currentRotation = transform.localRotation.eulerAngles;
currentRotation.y = Mathf.Clamp(currentRotation.y, mouseMin, mouseMax); // clamp y rotation
transform.localRotation = Quaternion.Euler (currentRotation);
}