void MouseRotate()
{
float rotaH = Input.GetAxis("Mouse X");
float rotaV = Input.GetAxis("Mouse Y");
transform.Rotate(Vector3.up * rotaH * rotateSpeed * Time.deltaTime, Space.World);
transform.Rotate(Vector3.right * -rotaV * rotateSpeed * Time.deltaTime,Space.World);
}
void AngleLimit()
{
float maxX = originRotateX + verticalRotateX;
float minX = originRotateX - verticalRotateX;
if(transform.localEulerAngles.x<180 && transform.localEulerAngles.x > maxX){
transform.localEulerAngles = new Vector3(maxX,transform.localEulerAngles.y,0);
}
else if(transform.localEulerAngles.x > 180 && transform.localEulerAngles.x <360-maxX ){
transform.localEulerAngles = new Vector3(360-maxX ,transform.localEulerAngles.y,0);
}
else if(transform.localEulerAngles.x<180 && transform.localEulerAngles.x < minX ){
transform.localEulerAngles = new Vector3(minX,transform.localEulerAngles.y,0);
}
else if(transform.localEulerAngles.x > 180 && transform.localEulerAngles.x <360+minX){
transform.localEulerAngles = new Vector3(360+minX ,transform.localEulerAngles.y,0);
}
float maxY = originRotateY + horizonRotateY;
float minY = originRotateY - horizonRotateY;
if(transform.localEulerAngles.y<180 && transform.localEulerAngles.y > maxY){
transform.localEulerAngles = new Vector3(transform.localEulerAngles.x,maxY,0);
}
else if(transform.localEulerAngles.y > 180 && transform.localEulerAngles.y <360-maxY ){
transform.localEulerAngles = new Vector3(transform.localEulerAngles.x,360-maxY ,0);
}
else if(transform.localEulerAngles.y<180 && transform.localEulerAngles.y < minY ){
transform.localEulerAngles = new Vector3(transform.localEulerAngles.x,minY,0);
}
else if(transform.localEulerAngles.y > 180 && transform.localEulerAngles.y <360+minY){
transform.localEulerAngles = new Vector3(transform.localEulerAngles.x,360+minY ,0);
}
}
|