ParticleSystem change color on runtime

Hello,

I am doing something like this to change in code the color of a ParticleSystem.

this.entityParticleEngine.particlesystem.colorGraph.curves[0].keys[0][1] = 0.2;
this.entityParticleEngine.particlesystem.colorGraph.curves[1].keys[0][1] = 0.2;
this.entityParticleEngine.particlesystem.colorGraph.curves[2].keys[0][1] = 0.85;

It works correctly if I do this during initialization. But on runtime, in the update(dt) function, it doesn’t affect the color. Do we have do some sort of update on the ParticleSystem, like what we do when we modify a material?

Thanks,

Yeah, I think all the graphs are converted into textures to use in the shader.

I don’t think there is an “API” way to update the graphs at runtime. If you call the internal methods entity.particlesystem.rebuild() or entity.particlesystem.rebuildGraphs()` that should work, though I can’t guarantee those methods will remain in the future…

1 Like

Thanks Dave,

rebuildGraphs() returns undefined, but rebuild() works fine and does the job. For the moment :wink:

1 Like