- Home /
random Color. Glitch?!?
hi i was trying to make a random color for each new enemy that has spawned. this is the code
var matColor : Color;
var r : float;
var b : float;
var g : float;
function Awake () {
r = Random.Range(0,255);
b = Random.Range(0,255);
g = Random.Range(0,255);
renderer.material.color = Color(r,b,g,255);
}
so when i try this r, b, and g are random and that works. but when i play the game and the enemy's come they all look really white.
Comment
Best Answer
Answer by Eric5h5 · May 20, 2010 at 12:25 AM
Color values are from 0..1, not 0..255.
function Awake () {
renderer.material.color = Color(Random.value, Random.value, Random.value);
}
var myColor = new Color(Random.value, Random.value, Random.value);
spark.renderer.material.SetColor("_TintColor", myColor);
I tried this, but always get ash color. why it happen so?
Your answer
Follow this Question
Related Questions
Random colors for particles? 0 Answers
OnMouseEnter random hover color 4 Answers
C# Randomize Background.Color Issues 1 Answer
Material doesn't have a color property '_Color' 4 Answers
Random objects don't overlap 1 Answer