I am working on a first person controller script and I need to clamp the rotation down so that it can only rotate up and down between -90 and 90 degrees. I googled it, found some solutions but they are clearly outdated because even when I copy verbatim, it underlines in red. Any up to date help would be greatly appreciated. Below is the code I am using:
private void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
float rotateXaxis = Input.GetAxis("Mouse Y");
float rotateYaxis = Input.GetAxis("Mouse X");
Vector3 movement = new Vector3(moveHorizontal, 0, moveVertical);
Vector3 lookAbout = new Vector3(rotateXaxis, rotateYaxis, 0);
transform.Translate(movement * walkSpeed * Time.deltaTime, Space.Self);
transform.eulerAngles.y = Mathf.Clamp(transform.eulerAngles.y, -90, 90);