- Home /
 
Why does this not scale smoothly? Any Ideas? Transform.localscale
I made this bit of code, and it works properly, however it gets smaller, glitches a bit and gets both bigger and smaller for a second, then finishes at the correct size. I have no idea why, any ideas? Thanks!
     Invoke("Return", .1);
         transform.localScale += Vector3(-.1,-.1,-.1);
 
     }
 }
 
 
 function Return () {
         transform.localScale -= Vector3(-.1,-.1,-.1);
 //    transform.localPosition += Vector3(0, 2.25, 0);
 //    yield WaitForSeconds (1);
 //        transform.localPosition -= Vector3(0, .25, 0);
 }
 
              
               Comment
              
 
               
              Answer by azmat786n · Dec 30, 2013 at 08:36 PM
 var scalingTR : boolean = false;
 var speed : float = 5;
 var currentValue : float = 1;
 var lastValue : float = 0.1;
 
 function Start() {
     scalingTR = true;
 }
 
 function Update() {
     if(scalingTR) {
        if(currentValue<=lastValue) {
           scalingTR = false;
        }
        else {
           currentValue = Mathf.MoveTowards(currentValue, lastValue, Time.deltaTime*speed);
           transform.localScale = Vector3(currentValue, currentValue, currentValue);
        }
     }
 }
 
              Your answer