代碼以下:html
1 bool RotateDelta(Vector3 direction) 2 { 3 direction.y = 0; 4 if (direction == Vector3.zero) 5 return true; 6 if (transform.forward == direction) 7 return true; 8 9 Quaternion target = Quaternion.LookRotation(direction); 10 float angle = Quaternion.Angle(target, transform.rotation); 11 float t = Mathf.Clamp01(720f * Time.deltaTime / angle); 12 transform.rotation = Quaternion.Lerp(transform.rotation, target, t); 13 return t == 1; 14 }
轉載請註明出處:http://www.javashuo.com/article/p-ppbnwkir-hx.htmlspa