I tried to Lerp the position of the gameObject using script, during my animation (using Unity’s animation feature)
At the end of the animation, I want the gameObject to move to a dynamic target, but it doesn’t move. The script locates where the target is, then Lerps the gameObject to it. I used an animation event to call the script.
I even added a blank frame to the animation, 10 seconds after the end of the animation, but that didn’t help.
[31174-screen+shot+2014-08-19+at+20.19.50.png|31174]
Any suggestion?
My script is the usual Lerp code:
var startPosition = gameObject.transform.position;
var endPosition = chosenTarget.transform.position;
var timer = 0.0;
var time = 3;
while (timer < time) {
timer += Time.deltaTime;
gameObject.transform.position.x = Mathf.Lerp(startPosition.x, endPosition.x, timer/time);
gameObject.transform.position.y = Mathf.Lerp(startPosition.y, endPosition.y, timer/time);
yield ;
}