hey guys, I was trying to clamp the rotation of the x-axis but for some reason, the z-axis kept changing from 180 to -180 degrees which messed up the clamping
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Came: MonoBehaviour
{
public float MouseSens;
float y;
float x;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
x -= Input.GetAxis("Mouse Y");
x = Mathf.Clamp(x, -90, 90);
y += Input.GetAxis("Mouse X");
transform.eulerAngles = new Vector3(x, y, 0) * MouseSens;
}
}
I’m new to unity so if someone could help me it would be much appreciated, ty!!