Unity Exporter: Fade-in and fade-out particles

Hello everyone,

I’m working on achieving a particle effect similar to the one shown in this playground, using the Unity exporter. Using the Particle Systems component, I’ve gotten the particles to fade-out as expected, but they do not fade-in. I tried adjusting the update function of the particle system in my code, but when I get the system like so:

let system = this.scene.getParticleSystemByID("StarParticles");

I get a BABYLON.IParticleSystem which doesn’t have an updateFunction parameter. Is there a different way to access the particle system that I’m missing? Or do I have to create the particle system entirely manually in my code to get the desired effect?

Thanks!

Pinging @MackeyK24 for assistance!

I figured it out. Not sure why I didn’t think of it, but all I had to do was cast it to a BABYLON.ParticleSystem. I’m now able to change my update function. However, when I use the update function in the mentioned playground, it breaks when I try to use a color other than white as seen here. Why is this happening?

1 Like

Can anyone help explain to me how this update function can be updated to work with other colors? I don’t really understand why this isn’t working. Thanks!

I do not understand the white issue ? is the issue the fact that it always goes to white ?
If it is the case it is because you accumulate colors in the update :

particle.color.addInPlace(this._scaledColorStep);

Thank you for the reply! No, the issue is that if color1 and color2 are set to colors other than white, the fade-in effect no longer works. It only works when both colors are set to white. I would like to fade-in OTHER colors. I’m not sure what changes need to be made to the update function to allow for this.

It is because your start color is random between 0 on 20 and knowing white is 1, most of your partlicles would start white:

https://playground.babylonjs.com/#ZVNDN#20

Thanks for the help! I fixed it by changing the blend mode to BLENDMODE_ADD and setting the alpha of both colors to 0. Here is the working playground.

1 Like