I am trying to set the color of a white sprite. It should be a smooth transition from green to red and back again, but when I run it, it only has 3 solid colors: green, yellow, and red. No colors in between - even though the values I am setting should give a smooth transition. Am I doing something wrong? The value os percent and colorPercent of the following code are correct when I debug it.
// Change the color based on health
float percent = mHeath / mMaxHealth;
float colorPercent = percent * 255.0f;
Color pColor = mHealthSprite.GetComponent<tk2dSprite>().color;
pColor.b = 0.0f;
pColor.g = colorPercent;
pColor.r = 255.0f - colorPercent;
mHealthSprite.GetComponent<tk2dSprite>().color = pColor;