📜  如何统一用鼠标环顾四周 - C# 代码示例

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

代码示例1
public class CameraController : MonoBehaviour //The script should be on the camera or on the player if it is a sphere
{
    
      Vector2 rotation = Vector2.zero;
    public float speed = 3; //the sensibility

    void Update () 
    {
        rotation.y += Input.GetAxis("Mouse X");
        rotation.x += -Input.GetAxis("Mouse Y");
        transform.eulerAngles = (Vector2)rotation * speed;
    }
}