VoidStars
❔ im dumb and stupid
just started learning C#, like, today. im making an FPS in Unity and started with movement/camera controls.
it had been going well, until i ran into trying to clamp the Y-axis movement of the player cam.
here's my code, the goal is to make the camera lock into place when it either hits 360 or 180, then change the rotation of the camera to be back within the 0-179 range, so that the player cant spin the camera 360. the locking-in-place works well, but i cant get it to revert back to the acceptable 0-180 range so the player can move the camera again.
expect very huge, glaring mistakes and absolutely ZERO optimization.
-----------------------------------------------------------------------------------------
mouseY = viewCam.localRotation.eulerAngles.y;
if (mouseY <= 179)
{
viewCam.localRotation = Quaternion.Euler(viewCam.localRotation.eulerAngles + new Vector3(0, mouseInput.y, 0));
}
else if (mouseY == 360)
{
mouseY == 0;
} else if (mouseY == 180) { mouseY == 179;
}
} else if (mouseY == 180) { mouseY == 179;
}
10 replies