我想知道是否有办法从二维精灵(预制件)的Z 轴旋转中每次按下“ButtonA”时添加(在我的情况下)120 度,并在每次按下“ButtonB”时减去 120 度。
这是我目前正在使用的代码,但它只向左旋转一次,向右旋转一次:
function TouchOnScreen ()
{
if (Input.touchCount > 0)
{
var touch = Input.touches[0];
if (touch.position.x < Screen.width/2)
{
var RSpeed = 10.0f
transform.rotation = Quaternion.Lerp ( transform.rotation,Quaternion.Euler(0,0,120), Time.deltaTime*RSpeed);
Debug.Log("RotateRight");
}
else if (touch.position.x > Screen.width/2)
{
var LSpeed = 10.0f
transform.rotation = Quaternion.Lerp ( transform.rotation,Quaternion.Euler(0,0,-120), Time.deltaTime*LSpeed);
Debug.Log("RotateLeft");
}
}
}
提前致谢!
注意:如果可以的话,请使用unityscript,我对编码很陌生,到目前为止我只知道unityscript。