1 回答

TA貢獻1752條經驗 獲得超4個贊
我看到您正在使用的移動控件Input.GetTouch(0).deltaPosition.y。但是,為您提供上次更新deltaPosition位置與當前位置之間的差異。因此,假設您的應用程序以每秒 60 幀的速度運行,它將返回每 1/60 秒的距離。當然,這將是一個接近于零的數字,我相信這就是為什么它看起來總是返回起始位置的原因
https://docs.unity3d.com/ScriptReference/Touch-deltaPosition.html
您將不得不以類似于使用鼠標方法的方式進行操作。將變量設置為touchStartonTouchphase.Began并將其與touch.position.
float touchStart = 0;
if (Input.touchCount > 0)
{
if (Input.GetTouch(0).phase == TouchPhase.Began) touchStart = Input.GetTouch(0).position.y;
//get the rotation based on the start drag position compared to the current drag position
zRotation = (Input.GetTouch(0).position.y - touchStart) * (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++;
}
}
不過我還沒有測試過,如果我錯了,請糾正我!
- 1 回答
- 0 關注
- 87 瀏覽
添加回答
舉報