标签:local mouse axis input 鼠标 start mat min tran
private GameObject center;
private float rotateSpeed = 40f;
private float rotateZ = 0;
private float minR = -15f;
private float maxR = 15f;
private float sensitity = 50f;
void Start()
{
//获取物体
center = GameObject.Find("center");
}
//鼠标拖动事件写在Update()中
if (Input.GetMouseButton(0))
{
float rotateY = center.transform.localEulerAngles.y - Time.deltaTime * sensitity*Input.GetAxis("Mouse X");
if (rotateY>=0&&rotateY<=180)
{
rotateZ += Time.deltaTime * sensitity * Input.GetAxis("Mouse Y");
}
else
{
rotateZ -= Time.deltaTime * sensitity * Input.GetAxis("Mouse Y");
}
//控制上下移动的范围
rotateZ = Mathf.Clamp(rotateZ, minR, maxR);
center.transform.eulerAngles = new Vector3(0, rotateY, rotateZ);
}
标签:local mouse axis input 鼠标 start mat min tran
原文地址:http://www.cnblogs.com/Study088/p/7126898.html