- Home /
Shrinking an object to Vector3.zero
Hey, folks! Thanks for your help.
I've been playing around with Vector3.Lerp, but I don't understand why what I'm trying isn't working. Basically, I've got a cube whose scale is (1,1,.1), and the code I've got here isn't working. Any advice or code examples? Thanks a bunch!
if(shrink)
{
if (t < 1.0)
{
t += shrinkspeed;
transform.localScale = Vector3.Lerp(Vector3.zero,startingScale, t);
}
}
Nice if you could say what if was doing during the "not working" phase. The most common problem, for javascript, is not declaring t as a float (so adding 0.01 just rounds back to 0.) Set t public to see it in the inspector. If that was the problem, the model would always be size 0.
Answer by testure · Jun 02, 2011 at 07:48 PM
personally I just use iTween for this sort of thing. iTween.ScaleTo(gameObject, Vector3.zero, time);
done like dinner.
Answer by flaviusxvii · Jun 02, 2011 at 06:29 PM
What you have will lerp the scale from Vector3.zero to startingScale.. as t moves from 0.0 to 1.0.
http://unity3d.com/support/documentation/ScriptReference/Vector3.Lerp.html
Your answer
Follow this Question
Related Questions
Using Lerp in a Constant Moving Object 1 Answer
Not Sure How to Get Around this Problem 1 Answer
Object movement with smooth start and end? 2 Answers
Do something when lerp reached target. 1 Answer
Vector3.Lerp making my object invisible. 2 Answers