我可以使用下面的代码来限制我的游戏对象的 z 旋转,但它总是会在我第一次触摸时改变 y 旋转。我只想旋转z轴。
private float zRotation;
public void RotateMove()
{
zRotation -= Input.GetTouch(0).deltaPosition.y * rotateSpeed * invert * Time.deltaTime;
// this limits the rotatioon
zRotation = Mathf.Clamp(zRotation, -80, 80);
//this rotates the game obj
lamp2Rotate.transform.eulerAngles = new Vector3(0.0f, 0.0f, zRotation);
}