Vector3.Slerp Manual     Reference     Scripting  
Scripting > Runtime Classes > Vector3
Vector3.Slerp

static function Slerp (from : Vector3, to : Vector3, t : float) : Vector3

Description

Spherically interpolates between two vectors.

Interpolates from towards to by amount t. The returned vector's magnitude will be interpolated between magnitudes of from and to.

t is clamped between [0...1].

// Animates the position in an arc between sunrise and sunset.
var sunrise : Transform;
var sunset : Transform;

function Update () {
// The center of the arc
var center = (sunrise.position + sunset.position) * 0.5;
// move the center a bit downwards to make the arc vertical
center.y -= 1;

// Interpolate over the arc relative to center
var riseRelCenter = sunrise.position - center;
var setRelCenter = sunset.position - center;
transform.position = Vector3.Slerp(riseRelCenter, setRelCenter, Time.time);
transform.position += center;
}

See Also: Lerp function.