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].
See Also: Lerp function.
var sunrise :
Transform;
var sunset :
Transform;
function Update () {
var center = (sunrise.position + sunset.position) * 0.5;
center -= Vector3(0,1,0);
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