Unity 之旋转

代码如下:

 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         }

转载请注明出处:https://www.cnblogs.com/jietian331/p/11017997.html

posted @ 2019-06-13 17:29  孤独の巡礼  阅读(484)  评论(0编辑  收藏  举报