x


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.

white enemy pic

more ▼

asked May 19 '10 at 11:53 PM

3dDude gravatar image

3dDude
2.6k 65 76 103

(comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest

Color values are from 0..1, not 0..255.

function Awake () {
   renderer.material.color = Color(Random.value, Random.value, Random.value);
}
more ▼

answered May 20 '10 at 12:25 AM

Eric5h5 gravatar image

Eric5h5
80.3k 42 132 521

cool thanks that works

May 20 '10 at 04:30 PM 3dDude

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?

Apr 02 at 07:16 AM sona.viswam
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x572
x507

asked: May 19 '10 at 11:53 PM

Seen: 1325 times

Last Updated: Apr 02 at 07:17 AM