Version: 2017.3
public static Vector3 Slerp (Vector3 a, Vector3 b, float t);

説明

球状に 2 つのベクトル間を補間します

Interpolates between a and b by amount t. The difference between this and linear interpolation (aka, "lerp") is that the vectors are treated as directions rather than points in space. The direction of the returned vector is interpolated by the angle and its magnitude is interpolated between the magnitudes of from and to.

パラメーター t は [0, 1] の範囲で制限されます。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Transform sunrise; public Transform sunset; public float journeyTime = 1.0F; private float startTime; void Start() { startTime = Time.time; } void Update() { Vector3 center = (sunrise.position + sunset.position) * 0.5F; center -= new Vector3(0, 1, 0); Vector3 riseRelCenter = sunrise.position - center; Vector3 setRelCenter = sunset.position - center; float fracComplete = (Time.time - startTime) / journeyTime; transform.position = Vector3.Slerp(riseRelCenter, setRelCenter, fracComplete); transform.position += center; } }

関連項目: Lerp, SlerpUnclamped.

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