Smoothing movement between any two particular values:
You have currentQuantity and desiredQuantity.
- only set desiredQuantity
- the code always moves currentQuantity towards desiredQuantity
- read currentQuantity for the smoothed value
Works for floats, Vectors, Colors, Quaternions, anything continuous or lerp-able.
The code: SmoothMovement.cs · GitHub
Another approach would be to use a tweening package line LeanTween, DOTween or iTween.
For score count-up (like a cash register whizzing lots of numbers upwards), I like this approach: