Linearly interpolates between a
and b
by t
.
The parameter t
is clamped to the range [0, 1].
When t
= 0 returns a
.
When t
= 1 return b
.
When t
= 0.5 returns the midpoint of a
and b
.
// Fades from minimum to maximum in one second
var minimum = 10.0; var maximum = 20.0;
function Update () { transform.position = Vector3(Mathf.Lerp(minimum, maximum, Time.time), 0, 0); }
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { public float minimum = 10.0F; public float maximum = 20.0F; void Update() { transform.position = new Vector3(Mathf.Lerp(minimum, maximum, Time.time), 0, 0); } }
See Also: LerpUnclamped, LerpAngle.