I am having troubles making my gun rotate up and down, and have limits, for example, I want the down limit to be 0 degrees, and the up limit to be 90 degrees.
Currently I can't figure out how to define that, and when the gun gets to one of the extremes, it gets stuck there and doesn't want to go back. Whats wrong?
Here's how I rotate the gun using an on-screen joystick
float lookAxisX = CrossPlatformInputManager.GetAxisRaw("VerticalLook");
if ((transform.localEulerAngles.x <= 360 && transform.localEulerAngles.x > 270) ||
(transform.localEulerAngles.x >= 0)
) {
transform.localEulerAngles += new Vector3(-lookAxisX * 2f, transform.localEulerAngles.y, transform.localEulerAngles.z);
}
Debug.Log("transform: " + transform.localEulerAngles);
Also right now, when the gun is at the default rotation (facing forward, its X angle is 0, and when it rotates up, it goes from 0 to 359,9, and then at 270 it gets stuck