Quantcast
Channel: Answers by "Lucanio"
Viewing all articles
Browse latest Browse all 18

Answer by Lucanio

$
0
0
The problem is you're using currentX as a starting position each time the Lerp is called, but the starting position should remain the same. This is what it should be instead: float startTime = Time.time; float startX = 0f; float currentX = startX; while( (currentX != finalX) && (Mathf.Abs(finalX-currentX))>marginOfError) { float localTime = Time.time-Time.deltaTime - startTime; float percentCovered = localTime/duration; //currentX = Mathf.Lerp (currentX, finalX, percentCovered); currentX = Mathf.Lerp (startX, finalX, percentCovered); yield return null; }

Viewing all articles
Browse latest Browse all 18

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>