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

参数

a 起始值,当 t = 0 时返回。
b 结束值,当 t = 1 时返回。
t 插值比率。

返回

Quaternion 在四元数 a 和 b 之间进行球形插值的四元数。

描述

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

这可用于创建一个旋转,以基于参数的值 a,在第一个四元数 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; } }

另请参阅:LerpSlerpUnclamped

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961