如题,本来想用鼠标右键控制摄像机旋转,但发现远程情况下Input.GetAxis(“Mouse X”)和Input.GetAxis(“Mouse Y”) 一直为0,无奈只能新增键盘控制摄像机旋转。
private void LateUpdate()
{
Rotate();
}
private void Rotate()
{
Vector3 angle = m_trans.eulerAngles;
if (Input.GetMouseButton(1))
{
float x = Input.GetAxis("Mouse X");
float y = Input.GetAxis("Mouse Y");
angle.x -= y * m_rotateSpeed;
angle.y += x * m_rotateSpeed;
}
if (Input.GetKey(KeyCode.LeftArrow))
{
angle.y -= 1;
}
if (Input.GetKey(KeyCode.RightArrow))
{
angle.y += 1;
}
if (Input.GetKey(KeyCode.UpArrow))
{
angle.x -= 1;
}
if (Input.GetKey(KeyCode.DownArrow))
{
angle.x += 1;
}
Quaternion rotation = Quaternion.Euler(angle);
m_trans.rotation = rotation;
}
|