鸟语天空
Mathf.SmoothStep()
post by:追风剑情 2017-6-9 18:10

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);
    }
}

评论:
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容