Hi, I can’t figure out how to stop the camera rotation arrived at a certain angle.
Imagine a man stretched out which must look right and left and his view can’t go over a certain angle.
I tried many solutions and this is one of them, but it’s not exactly the effect I wanted to give.
void Update () {
if (State2 == true)
{
// Camera poiting at the ceiling
Mytransform.localRotation = Quaternion.Euler(-65,0,0);
// reverse axis
y += Input.GetAxis("Mouse X");
x -= Input.GetAxis("Mouse Y");
Quaternion rotation = Quaternion.Euler(x, y, 0);
Mytransform.localRotation *= rotation;
if (Mytransform.localEulerAngles.y > 35f)
{
Mytransform.localEulerAngles = new Vector3( x, 35f, 0);
}
}
}