📜  mouselook 脚本统一 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:58.251000             🧑  作者: Mango

代码示例1
public float lookSpeed = 3;
private Vector2 rotation = Vector2.zero;
public void Look() // Look rotation (UP down is Camera) (Left right is Transform rotation)
    {
        rotation.y += Input.GetAxis("Mouse X");
        rotation.x += -Input.GetAxis("Mouse Y");
        rotation.x = Mathf.Clamp(rotation.x, -15f, 15f);
        transform.eulerAngles = new Vector2(0,rotation.y) * lookSpeed;
        Camera.main.transform.localRotation = Quaternion.Euler(rotation.x * lookSpeed, 0, 0);
    }