Quantcast
Channel: Latest Questions by Tanoshimi2000
Viewing all articles
Browse latest Browse all 91

How to loop through colors

$
0
0
I have racing cars and want to customize the color. Steer right and color goes up one. Steer left and color goes down one. In other systems, I can access the color as a Long and just increment that by 1 (or 10, or 100). Using the RGBA individually, I have it so that it increments R until R>1, then resets that to 0 and increments G, and so on. //Change color if (Input.GetButton("Fire3")){ var oldColor : Color; var v; var addV = 0.1; // or .01, or .001 depending upon speed I want. oldColor = transform.GetComponent("CarColor").car_color; v=oldColor.r+addV; if (v>1) { oldColor.r=0; v=oldColor.g+addV; if (v>1) { oldColor.g=0; v=oldColor.b+addV; if (v>1) { oldColor.b=0; v=oldColor.a+addV; if (v>1) { oldColor.a=0; } else oldColor.a=v; } else oldColor.b=v; } else oldColor.g=v; } else oldColor.r=v; transform.GetComponent("CarColor").car_color=oldColor; Is this the best way to handle this, or is there a better way to gradually shift through colors? I'd rather not use a colorpicker, since we're building for a steering wheel control and not a mouse interface.

Viewing all articles
Browse latest Browse all 91

Latest Images

Trending Articles



Latest Images