Unity-黑暗之魂复刻-鼠标输入

2019-05-13  本文已影响0人  祝你万事顺利

1.在键鼠输入类中新增值,用来控制鼠标输入

   [Header("===== Mouse Setting =====")]
    public bool mouseEnable = false;
    public float mouseSensitivityX = 1;
    public float mouseSensitivityY = 1;

2.当mouseEnable的时候玩家通过鼠标控制镜头旋转

        if (mouseEnable)
        {
            Jup = Input.GetAxis("Mouse Y")* mouseSensitivityY;
            Jright = Input.GetAxis("Mouse X")* mouseSensitivityY;
        }else
        {
            Jup = (Input.GetKey(keyJUp) ? 1.0f : 0) - (Input.GetKey(keyJDown) ? 1.0f : 0);
            Jright = (Input.GetKey(keyJRight) ? 1.0f : 0) - (Input.GetKey(keyJLeft) ? 1.0f : 0);
        }

3.隐藏游戏中的鼠标
Cursor.lockState设置成CursorLockMode.Locked

上一篇下一篇

猜你喜欢

热点阅读