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
网友评论