Quantcast
Viewing latest article 16
Browse Latest Browse All 47

Answer by khenkel

That's because you're using Time.deltaTime as the fraction parameter in Lerp(). This is NOT an actual time value but the time in seconds it took to complete the last frame. I didn't read up intensively on your code, but you could use your "t" variable instead as an example. In this case the object would move to the target position in exactly 1 second. **EDIT:** Try this out: private const float MOVEMENT_TIME = 5.0f; // Should move for 5 seconds void Update() { t += Time.deltaTime; float lerpFraction = t / MOVEMENT_TIME; var x = GetXv(); var y = GetYv(); transform.position = Vector3.Lerp(transform.position, new Vector3(x, y, 0), lerpFraction); }

Viewing latest article 16
Browse Latest Browse All 47

Trending Articles



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