Values are changing but the scale of sprite no.

Hey guys, I do need your help.

I have a bar (energyBar) that will scale up, on the amount of damageMade.

public void UpdateEnergyBar (SpriteRenderer energySprite, float currentEnergy, Vector3 energyScale)
		energySprite.transform.localScale = new Vector2 (energyScale.x + currentEnergy * 0.1f, 1);

	public void ColorMatchFunction(string color, float DamageAmount)
		ColorMatch colorMathc = ColorFactory.CreateColorFromName (color);
		colorMathc.DoColor (DamageAmount);
		string colorName = colorMathc.GetColorName ();

		currentEnergy += DamageAmount;
		currentEnergy = Mathf.Clamp (currentEnergy, 1, 1001);
		UpdateEnergyBar (blue, currentEnergy, energyBarScale); 

The problem is that it will not scale, eventhough the vector for scaling is changing and is working perfectly. I don’t know why the sprite won’t change it’s scale.


Putting a debug in the UpdateEneryBar.

Debug.Log ("energySprite scale on x axes   " + energySprite.transform.localScale.x);

It will show me in the console that the x will increase with the DamageAmount of points.

I don’t know why this is happening.

By the way, When Im exeting the game and playing again (in the Editor) the scale of the bar will not be as initialy (1,1,1), but will be as the thought scale (I mean that scale that was added with DamageAmount.


energySprite.transform.localScale = new Vector2 (energyScale.x + currentEnergy * 0.1f, 1);


energySprite.transform.localScale = new Vector3 (energyScale.x + currentEnergy * 0.1f, 1,1);

localScale is a Vector3 i don’t understand why you didn’t get an error for that