Hi so im creating a first person game but the camera can do a full circle on the x rotation and it looks weird while your playing. How do you clamp it between -90 and 90? This is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateCameraY : MonoBehaviour
{
float rotationSpeed = 600f;
// Update is called once per frame
void Update()
{
float mouseYInput = Input.GetAxis("Mouse Y");
transform.Rotate(Vector3.left * mouseYInput * rotationSpeed * Time.deltaTime);
Vector3 eulerAngles = transform.eulerAngles;
eulerAngles.z = 0;
}
}
If it looks weird for a first person camera its cause i did it myself. Pls help