static function SmoothStep(from:float,to:float,t:float):float
Description描述
Interpolates between min and max and eases in and out at the limits.
和Lerp类似,在最小和最大值之间的插值,并在限制处渐入渐出
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Example : MonoBehaviour
{
// Minimum and maximum values for the transition.
float minimum = 10.0f;
float maximum = 20.0f;
// Time taken for the transition.
float duration = 5.0f;
float startTime;
int number = 0;
void Start()
{
// Make a note of the time the script started.
startTime = Time.time;
}
void Update()
{
// Calculate the fraction of the total duration that has passed.
float t = (Time.time - startTime) / duration;
transform.position = new Vector3(Mathf.SmoothStep(minimum, maximum, t), 0, 0);
}
}