Vector3.Lerp

插值是数学上的一个概念,用公式表示就是:from + (to - from) * t;这也就是Lerp的返回值

用Lerp做了一个物体移动,设置了速度,但是并没有效果
物体仍然以非常快的速度,嗖一下到了终点
更改速度也没有效果

float normalisedTime = (float)((playableInput.GetTime()) / playableInput.GetDuration());
float tweenProgress = input.EvaluateCurrentCurve(normalisedTime);
position = Vector3.Lerp(input.startingPosition, input.endLocation.position, tweenProgress) ;

反复和API介绍,也没有发现哪里有问题

苦思冥想中突然顿悟了,写的没有问题,一定是用的时候出现了问题,仔细检查发现我把startPosition设置为移动物体本身了,特特记录一下,startPosition和endPosition是一个固定位置

猜你喜欢

转载自blog.csdn.net/u014481027/article/details/125928633