How to use Slerp? ( i reaed the script reference and did exacly what it says there)

yo mans!.. check this out… this is what it says on the docs

[COLOR="seagreen"]// Animates the position in an arc between sunrise and sunset.[/COLOR]

var sunrise : Transform;
var sunset : Transform;

function Update () {
[COLOR="seagreen"]// The center of the arc[/COLOR]
var center = (sunrise.position + sunset.position) * 0.5;
[COLOR="seagreen"]// move the center a bit downwards to make the arc vertical[/COLOR]
center -= Vector3(0,1,0);

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

so i did this on my game

pointA : Transform;

pointB: Transform;

happensonlyonce = false;

function Update ( ) {

if(!happensonlyonce ) {

transform.position = Vector3.Slerp(pointA, pointB, Time.time);
happensonlyonce  = true;
}

}

and it doesnt even give me the chance to test… a error pops up saying “the best way to overload yada yada yada”

weird huh?.. did i do something wrong?

Your code is not the same as the code from the docs. Take another look. Also, look at the definition in the docs again for the correct parameters that you can put in Slerp (Transform isn’t it).

–Eric

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

Note that the function for Slerp needs:

  • A start location (Obviously would be a Vector3)
  • an end location (Again, obviously would be a Vector3)
  • and a float (the amount of which to move by)

Also, you’re making it run only once, which is a bad idea. Slerp is a gradual thing, not an instant thing. If you simply want it to go from 1 position to the other, try doing a direct locational switch ( this.transform.location = Vector3( dest.x, dest.y, dest.z ) )