- Home /
Question by
hydraxic · Apr 03 at 10:32 AM ·
color change
changing object colour multiple times changes to weird colours
I'm new to unity so this might be a dumb mistake
So I have a script that changes the colour of an object whenever a variable in the script changes.
void Update()
{
if (hitcount == 3F)
{
gameObject.GetComponent<Renderer>().material.color = new Color(0.32F, 0.98F, 0.03F);
}
if (hitcount == 2F)
{
gameObject.GetComponent<Renderer>().material.color = new Color(1, 1, 0.03F);
}
if (hitcount == 1F)
{
gameObject.GetComponent<Renderer>().material.color = new Color(0.98F, 0.63F, 0.03F);
}
}
But instead of changing the colour to yellow then to orange, it changes the colour to a shade of green and then a darker shade of green. I tried this with Color32 as well but nothing worked.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613054922im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unable to Color.Lerp in two directions (Solved) 1 Answer
Change color on collision and keep track? 1 Answer
Trail renderer change color without changing all previous color 0 Answers
What on God's name is this yellow rubbish and how do I fix it? 1 Answer
Assigning R,G,B values to X,Y,Z to change colour in accordance with changing position 1 Answer