- Home /
Question by
Tech_egg · Feb 05, 2018 at 02:46 AM ·
2dbug-perhapsspriterenderercolor.lerp
Color.Lerp with Sprite Renderer jumping colors.
I have this soul-wrenching problem I've worked on for about 20 minutes, and it's because this sprite renderer is jumping colors.
private float health = 1;
//update
health -= 0.01f;
sr.color = Color.Lerp(new Color(255, 0, 0), new Color(0, 255, 0), health);
It first starts on yellow, which its not suppose to do, and after a while it jumps to red. I am appalled by this problem and I think it's somehow a bug.
Comment
Best Answer
Answer by Hurri04 · Feb 05, 2018 at 02:59 AM
use a range of 0f-1f, not 0-255.
in case you dont need fine-tuned custom colors you can also just use Color.red and Color.green btw.