Mathf.SmoothStep()

作者:追风剑情 发布于:2017-6-9 18:10 分类:Unity3d

public static float SmoothStep(float from, float to, float t);

在from与to之间平滑插值。

示例:

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    public float minimum = 10.0F;
    public float maximum = 20.0F;
    public float duration = 5.0F;
    private float startTime;
    void Start()
    {
        startTime = Time.time;
    }
    void Update()
    {
        float t = (Time.time - startTime) / duration;
        transform.position = new Vector3(Mathf.SmoothStep(minimum, maximum, t), 0, 0);
    }
}

标签: Unity3d

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号