Hi I am making a digital speedometer and I want it to change like a normal meter like: if speed is 10 on meter and the new speed is 50 it does not just show 50 on text instead gradually increase it.
here is what I have done:
int speed;
int textSpeed;
int speedfinal;
public Text text;
// Update is called once per frame
void Update()
{
speed = GameObject.Find("gamePlayManager").GetComponent<gamePlayManagerScript>().userSpeed;
textSpeed = int.Parse(text.text);
speedfinal = (int)Mathf.Lerp(textSpeed, speed, 0.1f);
text.text = speedfinal.ToString();
}
I am not sure if lerp is a good choice here to change text but that is what I know but it is adding 9 less then the orignal speed. Any idea how to do this. thanks.