Hi everyone,
The x-axis limit does not work, but the y-axis limits are works. How can fix this?
My codes:
public class MouseLook : MonoBehaviour
{
public float speedH = 2.0f;
public float speedV = 2.0f;
public float minimumX = 0F;
public float maximumX = 10F;
public float minimumY = -30F;
public float maximumY = 30F;
private float yaw = 0.0f;
private float pitch = 0.0f;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
yaw += speedH * Input.GetAxis("Mouse X");
yaw = Mathf.Clamp (yaw, minimumX, maximumX);
pitch -= speedV * Input.GetAxis("Mouse Y");
pitch = Mathf.Clamp(pitch, minimumY, maximumY);
transform.eulerAngles = new Vector3(pitch, yaw, 0.0f);
}
}