Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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;
    }
share|improve this question

closed as unclear what you're asking by Anko, BlueRaja - Danny Pflughoeft, MrCranky, Sean Middleditch, Josh Petrie Feb 8 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.

1  
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. –  Byte56 Feb 7 at 4:46
2  
This question appears to be off-topic because it is about debugging your code for you. –  Anko Feb 7 at 13:46

1 Answer 1

up vote 1 down vote accepted

The formula for progress looks wrong. I think it should be:

progress = (Time.time - startTime) / duration;
share|improve this answer
    
Ahhh! Thanks! Im quite new at this. I will keep that in mind. :) –  Lautaro Feb 7 at 13:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.