im trying to limit the rotation of the gun on the turret but it just snaps at min and max value.
Thanks.
`void FixedUpdate()
{
Mouse();
}
void Mouse()
{
Vector3 pos = Camera.main.WorldToScreenPoint(transform.position);
Vector3 dir = Input.mousePosition - pos;
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
angle = Mathf.Clamp(angle,160,-160);
Debug.Log(angle);
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
}`