Progress bar (i.e. Health, Mana, etc...) filling up gradually...

This question isn’t a duplicate; my method is different to any I’ve found online thus far, so I’ve decided to ask my own question. My values are all integers, no floats are involved apart from the value to be drawn on the bars, which is just for appearance. What I want to do is have it smoothly change from one value to the next if adding or subtracting. Here is my code related to the bars filling:

	private void HandleBar() {
		healthBar.fillAmount = Map(CurHealth, 0, MaxHealth, 0, 1);
		manaBar.fillAmount = Map(CurMana, 0, MaxMana, 0, 1);
		xpBar.fillAmount = Map(CurrentXP, 0, MaximumXP, 0, 1);

		EnemyHealthBarFill.fillAmount = Map(PlayerMovement.EnemyCurHealth, 0, PlayerMovement.EnemyMaxHealth, 0, 1);
	}

	private float Map(float value, float inMin, float inMax, float outMin, float outMax) {
		return(value - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
	}

I then run HandleBar() in Update() so it constantly keeps track of the bars and their progress. I’ve been playing around with it for quite a while trying to see how I could achieve this but to no avail… Thanks in advance :slight_smile:

Well you could just Lerp between the values. So if the Value used to be 1 and is now 2 you can make this:

speed = 10f //Defines how fast it switches between the 2 values

progressbarvalue = Mathf.Lerp(progressbarvalue, newValue, Time.deltaTime * speed);