【发布时间】:2022-08-15 07:48:43
【问题描述】:
我正在制作 FPS 并且我希望玩家旋转相机,我的代码适用于 PC,但如果我正在旋转相机并且我还触摸了开火按钮(或用我的另一根手指在其他任何地方),则可以在移动设备上使用相机向右旋转(这里是我的开火按钮),我不知道我是否可以做点什么,或者我需要取消 android 和 IOS 的发布,只为 PC 发布我的游戏
我的部分代码:
if (CanProcessInput())
{
// Check if this look input is coming from the mouse
bool isGamepad = Input.GetAxis(stickInputName) != 0f;
float i = isGamepad ? Input.GetAxis(stickInputName) : Input.GetAxisRaw(mouseInputName);
// handle inverting vertical input
if (InvertYAxis)
i *= -1f;
// apply sensitivity multiplier
i *= LookSensitivity;
if (isGamepad)
{
// since mouse input is already deltaTime-dependant, only scale input with frame time if it\'s coming from sticks
i *= Time.deltaTime;
}
else
{
// reduce mouse input amount to be equivalent to stick movement
i *= 0.01f;
#if UNITY_WEBGL
// Mouse tends to be even more sensitive in WebGL due to mouse acceleration, so reduce it even more
i *= WebglLookSensitivityMultiplier;
#endif
}
return i;
}