# Lerping back and forth in Coroutine [closed]

Im trying to lerp the scale of a game objecto to 30% its size and then back again, but all i get as output is "

Blippping Cursor

up scale 0

down scale 0

        IEnumerator Blip_cr (Vector2 position)
{
coordinateSelected = true;
SetPosition (position);

print ("Blippping Cursor");
var duration = 10f;
var startScale = transform.localScale;
var targetScale = startScale * 1.3f;
var startTime = Time.time;
var progress = 0f;

while (progress < 1) {
print ("up scale " + progress);
var newScale = Vector3.Lerp (startScale, targetScale, progress);
progress = duration / (Time.time - startTime);
transform.localScale = newScale;
yield return  null;
}
progress = 0;
startTime = Time.time;
while (progress < 1) {
print ("down scale " + progress);
var newScale = Vector3.Lerp (targetScale, startScale, progress);
progress = duration / (Time.time - startTime);
transform.localScale = newScale;
yield return  null;
}

coordinateSelected = false;
}


## closed as unclear what you're asking by Anko, BlueRaja - Danny Pflughoeft, MrCranky, Sean Middleditch, Josh♦Feb 8 '14 at 20:08

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• You forgot to tell us what the problem is and what you've tried already. This looks like it's just a debugging problem. Tell us what debugging steps you've already taken. – MichaelHouse Feb 7 '14 at 4:46
• This question appears to be off-topic because it is about debugging your code for you. – Anko Feb 7 '14 at 13:46

The formula for progress looks wrong. I think it should be:
progress = (Time.time - startTime) / duration;