您的位置:首页 > 移动开发 > Unity3D

Vector3 Lerp差值计算

2015-11-11 19:42 495 查看
转载自:http://game.ceeger.com/Script/Vector3/Vector3.Lerp.html

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的平均数。

0C#

JavaScript

// Animates the position to move from start to end within one second
//在1秒时间动画位置移动从from开始到to结束。
var start : Transform;
var end : Transform;
function Update () {
transform.position = Vector3.Lerp(start.position, end.position, Time.time);
}


另一个例子:

C#

JavaScript

// Follows the target position like with a spring
//像弹簧一样跟随目标物体
var target : Transform;
var smooth = 5.0;
function Update () {
transform.position = Vector3.Lerp (
transform.position, target.position,
Time.deltaTime * smooth);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  unity3d