How to restrict first person from turning 360 degrees when sitting?

I’m trying to not allow my player to fully turn when he is sitting down but can’t get it to work. I have the up/down axis working and restricts it to -35, 35, but when trying to restrict the left/right axis it doesn’t work and no errors are thrown. Here is my code with the left/right axis stuff commented out.

public class MouseLook : MonoBehaviour
{
public float mouseSensitivity = 100f;

public Transform playerBody;

private float xRotation = 0f;
float yRotation = 0f;
// Start is called before the first frame update
void Start()
{
//removes cursor from view
Cursor.lockState = CursorLockMode.Locked;
}

// Update is called once per frame
void Update()
{
//set the mouse x&y movement
float mouseX = Input.GetAxis(“Mouse X”) * mouseSensitivity * Time.deltaTime;
float mouseY = Input.GetAxis(“Mouse Y”) * mouseSensitivity * Time.deltaTime;
//decrease xRotation based on mouseY
xRotation -= mouseY;

if (PlayerMovement.isSitting)
{
//restricts the player from turning their head too far up/down
xRotation = Mathf.Clamp(xRotation, -35, 35);
// yRotation = Mathf.Clamp(yRotation, -35, 35);
}
else
{
xRotation = Mathf.Clamp(xRotation, -60f, 60f);
// yRotation = 0f;
}

transform.localRotation = Quaternion.Euler(xRotation, yRotation, 0f);
//move player left/right when mouse is going across x axis
playerBody.Rotate(Vector3.up * mouseX);
}
}[/code]

Please use code tags. See first forum post.

I recommend sticking some Debug.Log() statements both before and inside of your check-for-sitting if statement and see what numbers are coming through there, whether the player is even sitting when you think he is, etc.

I will try that thank you. And sorry forgot the code tags. Will use them next time I post