so im new to coding so my script is probably garbage but i just dont know how to clamp the rotation to 90 degrees and no tutorial or questions can be generalized so i can find an answer for my script.
can somebody help?
this is my script for the camera movement:
public class Camera : MonoBehaviour
{
public float mouseSensivity = 100f;
public Transform playerBody;
public Transform PlayerCamera;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
void Update()
{
float mouseX = Input.GetAxisRaw("Mouse X") * mouseSensivity * Time.deltaTime;
float mouseY = Input.GetAxisRaw("Mouse Y") * mouseSensivity * Time.deltaTime;
playerBody.Rotate(Vector3.up * mouseX);
PlayerCamera.Rotate(Vector3.right * mouseY * -1);
}
}