Hello.
I’m seriouisly spending too much time solving this and still stuck in here…
my project is about obtaining land as much as you can and the player has only 3 chances.
everytime the player gain land I want to count up from the last score to current score(last score + land I just obtained)
I’m using Mathf.Lerp and here it is.
private float land; //the score from each tries
private float totalScore; //the score combined
totalScore += Mathf.Lerp (0, land, Time.deltaTime * 0.5f);
slider.value = _totalScore; //a slider that shows current score.
Q01:
I put the Lerp method in Update() Function and it didn’t work.
(totalScore kept going up and didn’t stop)
if I put it in separated function, Lerp works only once showing very small value.
Q02:
after 1st try, float “land(ths land I just obtain)” is not the value that this Lerp should end with.
this Lerp shoud start from the last value to current value.
how should I set from & to values in Lerp insted of 0 & land?
someone please help me out of this 
thank you for reading anyway!
Did you read how Matf.Lerp works and what the parameters mean? It simply returns a value between the first two parameters based on the third parametes. If the third parameter is 0, it returns the first parameter. If third parameter is 0.5f, it returns the value that sits at the halfway point between the first two parameters.
You are feeding in Time.deltaTime *0.5f
which means that in every update you increase totalScore by some value that’s (depending on framerate) a few percent from 0 towards the value of land
. Actually the value you add is Time.deltaTime *0.5f * land
since your first parameter is 0.
What you probably want to do is store the currently shown score and the new score whenever you get more points and set a timer float to 0. Then in update Lerp it like
float pointAnimDurationSec = 2f;
float pointAnimTimer = 0f;
// var for storing the actual current score.
// end point of the Lerp
float currentScore = 0;
// var for storing the score just before points were last added
// start point of the Lerp
float savedDisplayedScore = 0;
// a variable for the "animated" score you should show in the UI.
// We can't put the result of Lerp into
// the vars above because that would mess up the result of the next Lerp
float displayedScore = 0;
// ^^ Added the word "displayed" because neither
// of these mark how many points th player really has.
// Afterall you animate the score just to make it pretty
void AddPoints(float points)
{
// A
// what if you get more points before last points finished animating ?
// start the animation again but from the score that was already being shown
// --> no sudden jump in score animation
savedDisplayedScore = displayedScore;
// B
// the player instantly has these points so nothng gets
// messed up if e.g. level ends before score animation finishes
currentScore += points;
// Lerp gets a new end point
pointAnimTimer = 0f;
}
void Update ()
{
pointAnimTimer += Time.deltaTime;
float prcComplete = pointAnimTimer / pointAnimDurationSec;
// don't modify the start and end values here
// prcComplete will grow linearly but if you change the start/end points
// it will add a cumulating error
displayedScore = Mathf.Lerp(savedDisplayedScore, currentScore, prcComplete);
}
With this code animating the new points always takes 2 seconds. Add a miltiplier to Time.deltaTime to get a slower or faster animation