Quantcast
Channel: Questions in topic: "interpolate"
Viewing all articles
Browse latest Browse all 93

How to lerp with a changing "from" value?

$
0
0
It's possible I'm not even using this right but basically I'm making a hunger system and I'm calling this in fixed update: public void Starve() { if(CurrentHunger > 0) { CurrentHunger = Mathf.Lerp(CurrentHunger, 0, HungerRate * Time.deltaTime); } } In this example, CurrentHunger starts as 100. Hunger rate is 15. My time.deltaTime is 0.02. With this use of lerp, basically, my from value is always changing. So: - 1 second it is 70 - 2 seconds it is 49 - 3 seconds it is 34.3 - 4 seconds its is 24.01 See? It's not decrementing linearly. Am I even using lerp right? And what do I need to do to fix this?

Viewing all articles
Browse latest Browse all 93

Trending Articles