public static Quaternion Slerp (Quaternion a, Quaternion b, float t);


ab 之间按 t 进行球形插值。参数 t 限制在范围 [0, 1] 内。

这可用于创建一个旋转,以基于参数的值 (/t/),在第一个四元数 (/a/) 到第二个四元数 (/b/) 之间平滑进行插值。如果参数的值接近于 0,则输出会接近于 /a/,如果参数的值接近于 1,则输出会接近于 /b/。

// Interpolates rotation between the rotations "from" and "to"
// (Choose from and to not to be the same as
// the object you attach this script to)

using UnityEngine; using System.Collections;

public class ExampleClass : MonoBehaviour { public Transform from; public Transform to;

private float timeCount = 0.0f;

void Update() { transform.rotation = Quaternion.Slerp(from.rotation, to.rotation, timeCount); timeCount = timeCount + Time.deltaTime; } }