I stumbled against a weird (in my eyes) problem while using Vector3.Lerp. If i place the lerp function inside an if statement which should control when the lerp should actually take place and when the object should stop, it does not behave like i want it to.
The problematic if statement:
I printed the results and canMove switches correctly between true and false. Distance also works correctly. The problem is, once the lerp is turned on, it wont stop, even though i have an if statement which should stop it each time the distance is bigger than 5. My question is if lerp is "update" independent (if such a thing exists) or if there is another to stop a Lerp movement.
I am fairly new to scripting so i bid my excuses if this is something obvious which i cant see to unravel.
Anyways, thanks in advance.
asked Dec 08 '11 at 08:24 AM
its easy and check your moving object reached end position means just break that loop....thats it... :-)
answered Dec 08 '11 at 12:39 PM
Try printing i, see if it ever becomes >1.0.
The time calculations in your moveLetters function looks suspicious to me.. if rate is equal to 1.0 getting divided by time, then it will keep getting smaller and smaller.. and if i is Time.deltaTime multiplied by a number that's constantly getting smaller (and never >1.0) then I don't think your while statement can escape.
answered Dec 08 '11 at 10:01 AM