| from | 要与 to对齐的单位四元数。 | 
| to | 目标单位四元数。 | 
| maxDegreesDelta | 此旋转允许的最大角度(度)。 | 
                  Quaternion 一个单位四元数,它在 maxDegreesDelta 的角度步长下朝向 to 旋转。
将旋转 from 旋转到 to。
通过 maxDegreesDelta 的角度步长,将 from 四元数旋转到 to。旋转不会超过 to 四元数。负的 maxDegreesDelta 值将远离 to,直到旋转方向完全相反。
using UnityEngine;
public class Example : MonoBehaviour { // The object whose rotation we want to match. public Transform target;
// Angular speed in degrees per sec. public float speed = 1.0f;
void Update() { // The step size is equal to speed times frame time. var step = speed * Time.deltaTime;
// Rotate our transform a step closer to the target's. transform.rotation = Quaternion.RotateTowards(transform.rotation, target.rotation, step); } }