1,Mathf.Lerp(float a, float b, float t)
:线性插值,如果需要达到t值,需要一个逐渐变大的t值。
另外可以将a设置为当前结果,t设置为一个恒定值,这样会得到一个逐渐减速的值,最后结果会无限接近于b
返回结果按照如下方式计算:return (a + ((b - a) * Clamp01(t)));
2,Mathf.MoveTowards(float current, float target, float maxDelta)
:线性变化
if (Abs((float) (target - current)) <= maxDelta)
{
return target;
}
return (current + (Sign(target - current) * maxDelta));
3,Mathf.SmoothStep(float from, float to, float t):
先加速后减速。
和Lerp一样的处理方式,只是变化曲线是一个先加速后减速的结果
4,Mathf.SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed = Mathf.Infinity, float deltaTime = Time.deltaTime):
非匀减速曲线。
和Lerp的第二种使用方式类似,结果会无限接近于target