Mathf.Lerp Manual     Reference     Scripting  
Scripting > Runtime Classes > Mathf
Mathf.Lerp

static function Lerp (a : float, b : float, t : float) : float

Description

Interpolates a towards b by t. t is clamped between 0 and 1.

When t = 0 returns from. When t = 1 return to. When t = 0.5 returns the average of a and b.

var minimum = 10.0;
var maximum = 20.0;
// Fades from minimum to maximum in one second
function Update () {
transform.position.x = Mathf.Lerp(minimum, maximum, Time.time);
}