Vector3.Slerp

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

Description

Spherically interpolates between two vectors.

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

t is clamped between [0...1]. See Also: Lerp function.

JavaScript
// 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 -= Vector3(0,1,0);

// 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;
}

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
public Transform sunrise;
public Transform sunset;
void Update() {
Vector3 center = (sunrise.position + sunset.position) * 0.5F;
center -= new Vector3(0, 1, 0);
Vector3 riseRelCenter = sunrise.position - center;
Vector3 setRelCenter = sunset.position - center;
transform.position = Vector3.Slerp(riseRelCenter, setRelCenter, Time.time);
transform.position += center;
}
}

import UnityEngine
import System.Collections

class example(MonoBehaviour):

public sunrise as Transform

public sunset as Transform

def Update():
center as Vector3 = ((sunrise.position + sunset.position) * 0.5F)
center -= Vector3(0, 1, 0)
riseRelCenter as Vector3 = (sunrise.position - center)
setRelCenter as Vector3 = (sunset.position - center)
transform.position = Vector3.Slerp(riseRelCenter, setRelCenter, Time.time)
transform.position += center