Why does my random colour generator always spit out the same colour?
I'm using rC, gC and bC to store random values to use in colour generation, but they always generate the same red colour even tho the values change. why? Here's the code:
case 1:
rC = Random.Range(.0f,.3f);
print(rC);
gC = Random.Range(0.0f, .5f);
print(gC);
bC = Random.Range(0.0f, .7f);
print(bC);
aC = Random.value;
print(aC);
bWhich = Random.Range((-.5f / lvl), (.5f / lvl));
aWhich = Random.Range(1, 3);
vieuLvl = 1;
for (int i = 0; i <= 15; i++)
{
xPos = cube[(i)];
if (i <= 4)
{
yPos = -1f;
print("5");
}
else if (i <= 9)
{
yPos = 0f;
print("10");
}
else if (i <= 15)
{
yPos = 1f;
print("15");
}
if (i != special)
{
GameObject masd = Instantiate(real, new Vector3(xPos, yPos, 0f), transform.rotation) as GameObject;
GO.Add(masd);
masd.GetComponent<Renderer>().material.color = new Color(rC, gC, bC, aC);
print(masd.GetComponent<Renderer>().material.color);
}
else if (i == special)
{
GameObject macgiver = Instantiate(fake, new Vector3(xPos, yPos, 0f), transform.rotation) as GameObject;
GO.Add(macgiver);
switch (aWhich)
{
case 1:
macgiver.GetComponent<Renderer>().material.color = new Color((rC + bWhich), gC, bC, aC);
break;
case 2:
macgiver.GetComponent<Renderer>().material.color = new Color(rC, gC + bWhich, bC, aC);
break;
case 3:
macgiver.GetComponent<Renderer>().material.color = new Color(rC + bWhich, gC, bC+bWhich, aC);
break;
}
}
}
Comment
just to be clear. Do you mean all "real"s are the same red, or every time the code is ran (case 1) you get the same red color?
All real are the same red colour every single time I run the program.
Your answer
Follow this Question
Related Questions
How to make RANDOM COLOR on shader 1 Answer
How to change the color of my text object? 1 Answer
Is there any way to make a gradient within unity?,Is there any way to make a gradient? 1 Answer
Image Colour change not working with anythign other than base preset colours 2 Answers
Color.Lerp over HP 1 Answer