So I’m making a first person controller, and this code is my camera aiming code:
But I can still aim 360 degrees around verticaly… How would I clamp the vertical rotation of the camera?
public float mouseSensitivity = 5;
public float rotVertical = 0;
public float viewRange = 60;
Transform cameraTransform;
void Start () {
cameraTransform = Camera.main.transform;
}
void Update () {
//Camera
float rotHorizontal = Input.GetAxisRaw ("Mouse X") * mouseSensitivity;
transform.Rotate (0, rotHorizontal, 0, Space.World);
rotVertical = Input.GetAxisRaw ("Mouse Y") * mouseSensitivity;
cameraTransform.localRotation *= Quaternion.Euler (-rotVertical, 0, 0);
}