是的,我是一个爱幻想的人。
Vector3.Lerp 插值
static function Lerp (from : Vector3, to : Vector3, t : float) : Vector3
Description描述
Linearly interpolates between two vectors. 两个向量之间的线性插值。 Interpolates from towards to by amount t. 按照数字t在from到to之间插值。 t is clamped between [0...1]. When t = 0 returns from. When t = 1 returns to. When t = 0.5 returns the average of from and to.
t是夹在 [0...1]之间,当t = 0时,返回from,当t = 1时,返回to。当t = 0.5 返回from和to的平均数。
public Transform start,end;//起始位置 float smooth = 5;//移动速度 void Update () { //1 transform.position = Vector3.Lerp(start.position, end.position, Time.time);//1秒动画 平滑移动 自身从 start位置到 end位置 //2 //transform.position = Vector3.Lerp(start.position, end.position, 0.5f);//始终在两物体位置的中间位置 //3 //transform.position = Vector3.Lerp(gameObject.transform.position, end.position, Time.deltaTime * smooth);//弹簧效果 }
是的,我是一个爱幻想的人。 //1 移动动画可以做,好像瞬间想到了好多可以应用到的哦。。。飞机、导弹路线,定点发射。 界面UI,人物移动动画,噻,好像是能幻想到好多。。。 //2 可以定 在两个物体 点到点 之间的 某位置上。。。物体之间的反作用,吸铁石排斥、扔出去再给我收回来。乌龟咬住了手,手动乌龟也动。 噻,好像也不少 //3 既然弹簧效果可以做,那拉面呢,橡皮筋呢,弹弓呢,跳绳呢。。。
来自:一笑而过2号
|