Material Colors...

Hello everyone,

I’ve got probably a simplistic question regarding material colors. What is the proper way to have a certain material color value increase or decrease if the material is set to say ‘blue’?

To tie into that as well, is there a way to dynamically change the material color if a certain action takes place? I’ve got objects that have at least three different material colors to them and was wondering the best way to switch them while playing a game.

hello !.

you can change the color by :

renderer.material.color = Color.blue;  // in case is blue

you can declare vars to set a color corresponding to a desired object…

Thanks for the response, it helped!

So is there a way to change specific materials assigned to an object? Like if there are 3 different types of materials on specific parts of an object (red,blue,green). So for an example you have a square object that has one material handling the “outline” (blue) of the object and another material that is the color (red) of the object. Is there a way to switch the outline color to green while keeping the main color red of the object?

BlackOut, are you using Toonshading for outline? if in that case you can change the color…
or some other material shader?

No, I’m not using toon for the edges. What I had in mind was Tron-like where an object would be a basic black color and then the line/stripes going around the object would be the colors. Right now I have materials doing that but was wondering how to dynamically change the line/stripe colors when certain actions take place.

I think I figured out what I need to do for my case. I just need to set the lines/stripe material as the first one in the list. So that way I can just use:

renderer.material.color = Color.blue;

Because for my purpose that call changes the first material in the list only, so I just need to adjust my materials as to where the ones I need changed as the first on the list.

Thanks for the help

Now this leads me to another question haha! If you have 4 different materials, how do you reassign them in a different order but still keep the area they change the color to?

You could just change them by using renderer.materials[0].color, renderer.materials[1].color, and so on…

if you have 4 materials it will be accessible as the array renderer.materials[ ]

renderer.materials[0].color = Color.blue;

Perfect! Thanks for all the help guys