I've been trying to limit the Y-axis of the camera rotation but I'm out of depth until now. I'd looked up many tutorials and I found the clamping method, but I seem can't get it to work on my code, and all the tutorials I found is using them in Update(), while I'm using a button to rotate the camera. Here's the code:
public void RotateLeft()
{
cameraY = Mathf.Clamp(cameraY, minAngle, maxAngle);
if(cameraY >= minAngle)
{
Camera.main.transform.Rotate(0,-cameraY,0);
}
}
public void RotateRight()
{
cameraY = Mathf.Clamp(cameraY, minAngle, maxAngle);
if(cameraY <= maxAngle)
{
Camera.main.transform.Rotate(0,cameraY,0);
}
}
Does clamping works outside an Update()? What am I missing?
Thank you in advance.