我有一个代码可以预测LateUpdate(). 它可以在 PC 和鼠标上完美运行。下面是使用鼠标时的代码:
if(Input.GetMouseButton(0)){
//get the rotation based on the start drag position compared to the current drag position
zRotation = (Input.mousePosition.y - mouseStart) * (manager.data.sensitivity/15);
zRotation = Mathf.Clamp(zRotation, -manager.data.maxAimRotation, manager.data.maxAimRotation);
}
//reset the rotation if the player is not aiming
else if((int) zRotation != 0){
if(zRotation > 0){
zRotation --;
}
else{
zRotation ++;
}
}
我现在想把它移植到 Android 上,所以我在玩Input.Touch. 我将上面的代码更改为以下内容:
if (Input.touchCount > 0)
{
//get the rotation based on the start drag position compared to the current drag position
zRotation = (Input.GetTouch(0).deltaPosition.y) * (manager.data.sensitivity / 15);
zRotation = Mathf.Clamp(zRotation, -manager.data.maxAimRotation, manager.data.maxAimRotation);
}
//reset the rotation if the player is not aiming
else if ((int)zRotation != 0)
{
if (zRotation > 0)
{
zRotation--;
}
else
{
zRotation++;
}
}
但是zRotation它不起作用,因为它在鼠标中起作用。它在每一帧后不断重置到起始位置。它几乎看起来像抖动。
我究竟做错了什么?
温温酱
相关分类