【发布时间】:2020-11-16 10:24:57
【问题描述】:
我可以使用下面的代码来限制我的游戏对象的 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);
}
【问题讨论】:
标签: c# unity3d touch-event screen-rotation clamp