PARTICLE: Color animaton

In the Particle Animator tab, I am trying to do a ramp up in the particle’s color which requires more than the default 5 colors, is it possible to increase the color animation array ?

Cant say for sure (I dont think so) but if you check out Forests particle tutorial on the wiki, it explains how to animate UV’s really well…Which would to it for you with a texture.
AC

…and you have access to the particles directly from code, but that can be a bit messy if you just want to do something basic.

-Jeremy

I think you can do it with textures, but they wont blend like the colour animation does. May be a solution without coding?

http://unity3d.com/support/documentation/Components/class-ParticleRenderer.html#AnimatedTextures

Right at the bottom there,

AC

Thanks guys.

L

Here’s something. It supports unlimited colors that can be assigned in the inspector. I made this while I was eating my lunch, so you will have to tinker with it to get exactly what you want. The timing ratios might be off and it doesn’t handle particles with different minEnergy and maxEnergy. Turn off the DoesAnimateColor? property first to avoid extra calculations.

var colorArray : Color[];
private var maxEnergy : float;

function Start () {
	maxEnergy = particleEmitter.maxEnergy;
}

function LateUpdate () {
    var particles = particleEmitter.particles;
    for (var i=0; i<particles.Length; i++) {
    	for (var j=colorArray.length; j >1; j--) {
    		if ((particles[i].energy <= maxEnergy*(j-1)/(colorArray.length -1))  (particles[i].energy > maxEnergy*(j-2)/(colorArray.length - 1))) {
    			particles[i].color = Color.Lerp(colorArray[colorArray.length - j], colorArray[colorArray.length - j + 1], maxEnergy*(j)/(colorArray.length) - particles[i].energy);

    			break;
    		}
    	}
    }
    particleEmitter.particles = particles;
}

Sorry, but there wasn’t any time to comment on it either.

edit: I forgot to add break; to the j for loop. Actually, I am not sure if that is the correct syntax. I am fairly new to java.

Thanks Carey, productive lunches eh.

Now the documentation doesn’t explain Max Particle Size, anyone knows how this works ? I am using some of my particle systems as sort of decals, replaces geometry quite nicely - the only problem is that when the camera gets close to the billboards, they start to recede.
I tried Max Part Size = 1 and the shrinking is gone, now the billboards move erratically - how do I fix that?

Hi Carey,

I tried out your script but it didnt work (Unity1.6.2), is there something specific about it that only works in 2.0?

I added a default particle system, added your script, made 9 colours, and unchecked doesAnimteColour.

Just curious if its something I’m doing wrong?
Cheers
AaronC

I couldn’t say for sure, I haven’t been around long enought to know 1.6.2.

Only thing I can think of is to try disabling my script and turning on animate color just to make sure your shader/material works with the animated color.

Something that I have been thinking about in the last couple of days is that you can often use just the five colors to display many other colors. For example, there is no need to declare Color1 to be red, Color2 to be orange and Color3 to be yellow. With just Color1 = Red and Color2 = Yellow, orange will be displayed by the default Lerp’ing.

I didnt get this script to work, did anyone else?
AC