I have a script that says when i hit pointA, lerp to pointB. It works great but when I go back to point A it wont repeat the lerp movement. Additionally, how would i set the Vector3 position to an actual gameobject, my pointA and pointB?
var pointA:Vector3;
var pointB:Vector3;
var time:float = 10.0;
var i:float = 0.0;
private var rate:float = 0.0;
var detector : ClimbDetectionScript;
var pointAobject : GameObject;
var pointBobject : GameObject;
function Update ()
{
MoveObject(this.transform, pointA, pointB, time);
}
function MoveObject (thisTransform : Transform, startPos : Vector3, endPos : Vector3, time : float)
{
rate = 1.0/time;
if (i < 1.0)
if (detector.startSpot == true)
{
i += Time.deltaTime * rate;
thisTransform.position = Vector3.Lerp(startPos, endPos, i);
}
}