【发布时间】:2020-05-19 22:21:55
【问题描述】:
我需要从之前的位置转动轮子。但每次触摸屏幕时它都会重置。当触摸结束(释放)然后再次触摸时会出现问题。
我需要存储对象的旋转值。
任何帮助表示赞赏。谢谢
direction = Camera.main.ScreenToWorldPoint(touch.position) - transform.position;
angle = (Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg)-90;
rotation = Quaternion.AngleAxis(angle, Vector3.forward);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, speed * Time.deltaTime);
oldRotation = transform.rotation;
【问题讨论】:
-
您能否将其余代码添加到上下文中?特别是当问题在于您处理触摸时,例如处理触摸的部分会有所帮助......
标签: c# unity3d rotation transform