【发布时间】:2014-03-16 00:52:44
【问题描述】:
我正在为 iOS 设备创建游戏。我希望我的玩家或游戏对象根据触摸旋转。我在 touchPhase.Moved 中使用以下代码
if (Input.touchCount > 0 && Input.GetTouch (0).phase == TouchPhase.Moved)
{
coinTouched = true;
if (coinTouched)
{
Vector2 currentTouchPosition = Input.GetTouch (0).position;
endPos = new Vector3 (currentTouchPosition.x, 0, currentTouchPosition.y);
endTime = Time.time;
gameObject.transform.rotation = Quaternion.Euler(0f,Input.GetTouch(0).deltaPosition.x * 1.0f,0f);
}
}
但它的行为很尴尬。它旋转了几乎 180 度,然后向相反的方向移动,再经过 180 度后,它向相反的方向旋转,依此类推。请帮帮我。
谢谢。
【问题讨论】:
标签: c# ios unity3d game-physics unityscript