I’m still having problems here. It won’t stop shrinking when the localScale is less than the target scale. I even printed out the .x value to see if it was a float and it is.
I have the targetScale set at .6f, and when transform.localScale.x goes below .6 it doesn’t stop shrinking. However, if I swap the < to > in the comparison, it works. So I’m not understanding why it can’t detect the < comparison.
The lerp will shrink the local scale to the targetScale, but it won’t be less than it. If you change the if statement to read <= instead of just < I wouldn’t be surprised if it worked. You may also want to look into Mathf.Approximately and Vector3.Distance. One will tell you the distance between two vector3’s, and the other will tell you when a float is approximately equal to another float.
I’m not quite sure how it operates. Here’s my variable …
targetScale = .6f;
That means I want to shrink it until it’s .6 the original size? Either way, when I print transform.localScale.x it prints out some low number like .32 when the size I wanted it to stop at was .6.
Thanks, I got it, but forgot to reply that I had gotten it. I’m curious though, how do I slow the rate of shrinking? No matter what value I change it doesn’t seem to slow it down.
this is just a sample, drag the scripts to a cube object and you will understand how lerp work
just show you a way only.
my Lerp is not doing inside the if statement.
But your lerp are