Sunday, November 27, 2011

Triple Feature: Particle Texture Fade

Here's a solution to something that annoyed me for weeks.

One of the player's weapons fires what can best be described as lightning rings. They can bounce off walls. When they explode, they expand and fade away.

Or…they're supposed to fade away. In practice, this happens:
The rings expand, but they don't become more transparent, and they don't disappear. For some reason, the unity scripting language can't find the color attribute of the explosion material.

Yeah…some reason. In the unity programming language, you reference most material's colors with this:
renderer.material.GetColor("_Color");
Or, more simply…
renderer.material.color

But that doesn't work with materials that use particle shaders.

After extensive investigation, some experimentation, and a failed attempt to use a script I got off the 'net, I concluded that particle shaders don't have the color attribute. So, the question is, what do they have?

I managed to find a script for a particle shader, and found that they have this:

renderer.material.GetColor("_TintColor");


Bam, problem solved.





No comments:

Post a Comment