Unity3d 设备上的统一对象旋转速度不同
我有一个对象,当用户将手指拖动到它上面时,我会向左或向右旋转,在iPad4上,这样做非常平滑 然而,在iphone6plus或nexus4上,对阻力的响应有一个非常明显的滞后,有时它几乎不旋转 这就是我在更新方法中所做的…我是否做错了什么?重新确保旋转的感觉和外观在设备上的工作相同吗Unity3d 设备上的统一对象旋转速度不同,unity3d,rotation,touch,transform,Unity3d,Rotation,Touch,Transform,我有一个对象,当用户将手指拖动到它上面时,我会向左或向右旋转,在iPad4上,这样做非常平滑 然而,在iphone6plus或nexus4上,对阻力的响应有一个非常明显的滞后,有时它几乎不旋转 这就是我在更新方法中所做的…我是否做错了什么?重新确保旋转的感觉和外观在设备上的工作相同吗 void Update () { // test for touch if (Input.touchCount == 1) { // grab reference to thi
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) {
}
}
}
}
时间.延迟时间
time.deltaTime将确保与帧速率没有依赖关系,因为“deltaTime”指的是从最后一帧经过的时间。通常在更新方法中的计算中添加always time.deltaTime,尤其是涉及移动或时间计数的计算,或者可以在FixedUpdate方法中更新旋转/位置。但是大多数时候使用deltaTime是最好的选择。谢谢大家的帮助;-)感谢;-)
-userTouch.deltaPosition.x * _rotationSpeed * time.deltaTime