【发布时间】:2014-11-04 08:07:24
【问题描述】:
我有一个对象,当用户将手指拖过它时我会向左或向右旋转,而在 iPad4 上这非常流畅。
但是,在 iPhone 6 Plus 或 Nexus 4 上,在响应拖动到有时几乎不旋转的地步时会有非常明显的延迟?
这就是我的更新方法...我做错了什么以确保旋转感觉和外观在不同设备上都相同吗?
void Update () {
// test for touch
if (Input.touchCount == 1) {
// grab reference to this touch
Touch userTouch = Input.GetTouch(0);
// ray from cameara to point of finger touch
Ray ray = Camera.main.ScreenPointToRay( Input.GetTouch(0).position );
// hit object to record details of what was hit (touched)
RaycastHit hit;
// if the hit was on the Collider object
if ( Physics.Raycast(ray, out hit) && hit.collider.gameObject.name == "MyObject") {
// process the relavent phase...
if (userTouch.phase == TouchPhase.Began) {
}
else if (userTouch.phase == TouchPhase.Moved) {
// user is moving finger so rotate model
transform.Rotate(0.0f, -userTouch.deltaPosition.x * _rotationSpeed, 0, Space.Self);
}
else if (userTouch.phase == TouchPhase.Ended || userTouch.phase == TouchPhase.Canceled) {
}
}
}
}
【问题讨论】:
标签: unity3d rotation touch transform