我有一个带有敏感度变量的脚本,但是无法弄清楚我在代码中的位置。任何专家都可以在这里帮助我吗?
我要添加此:
public float sensitivity = 5.0f;
进入四元数旋转的代码:
switch (firstTouch.phase)
{
case TouchPhase.Began:
firstpoint = firstTouch.position;
xAngTemp = xAngle;
yAngTemp = yAngle;
break;
case TouchPhase.Moved:
secondpoint = firstTouch.position;
//Mainly, about rotate camera. For example, for Screen.width rotate on 180 degree
xAngle = xAngTemp + (secondpoint.x - firstpoint.x) * 180.0f / Screen.width;
yAngle = yAngTemp - (secondpoint.y - firstpoint.y) * 90.0f / Screen.height;
//Rotate camera
this.transform.rotation = Quaternion.Euler(yAngle, xAngle, 0.0f);
character.transform.rotation = Quaternion.Euler(yAngle, xAngle, 0.0f);
break;
}
可能不是专家,但简单地将其相乘怎么办
xAngle = xAngTemp + (secondpoint.x - firstpoint.x) * 180f * sensitivity / Screen.width;
yAngle = yAngTemp - (secondpoint.y - firstpoint.y) * 90f * sensitiviy / Screen.height;
尽管我建议宁愿使用Vector2
以便能够对x和y使用单独的灵敏度
public Vector2 sensitivtiy = Vector2.one * 5f;
...
xAngle = xAngTemp + (secondpoint.x - firstpoint.x) * 180f * sensitivity.x / Screen.width;
yAngle = yAngTemp - (secondpoint.y - firstpoint.y) * 90f * sensitiviy.y / Screen.height;