How to restrict 2d rotation

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: Using code tags properly

To solve your problem:

  • keep a float that is the angle, adjust that, clamp that

  • “drive” the float out to the rotation using Quaternion.Euler( 0, angle, 0) (around whatever axis you want)

More on this notion: Turret aiming/rotating:

ALSO: if you are adjusting a quantity yourself, ALWAYS multiply by Time.deltaTime or else your game will behave differently at different frame rates.