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 关注
- 89 浏览
添加回答
举报