How can I change a particle's colour at runtime?

Hi there,

I’ve been trying to make a simple static mesh object that has a particle system attached, which will be activated by some event (say like on any damage received).

To add variety, I added MID to both the static mesh and the particle, using the construct graph. Both materials are simple, the SM material has one vector parameter node linked to base colour; and the emitter material is additive and has one vector parameter linked to emissive colour. And then in the event graph I set up this event to test it, on G pressed, change both MID to one random colour; then on F pressed activate the particle.

The result is that when I press G the SM changes colour properly, but when I press F the particle activates and it’s still the default colour.

I’ve tried particle parameter but it didn’t work either…

This is the construction graph of my MID attempt:

This is the event graph of my MID attempt:

This is the material of my MID attempt, really can’t get any simpler:

This is the detail panel of my Particle Parameter attempt:

50257-pparameterbpd.png

This is the event graph of my PP attempt:

I’d attach the material and particle settings of my PP attempt but obviously I’ve attached too many pictures… Thanks for helping.

Hi vito -

You will need to call a Set Material to the Created MID on your Particle System on Event Begin Play, otherwise the Particle will not accept the new Material from the Construction Script.

Thank You

Eric Ketchum

Here is the Set up:

Awesome! Thanks Eric! This indeed solved my problem and worked on both CPU and GPU sprites! Just out of curiosity, can I do this with particle parameter? Is there something to pay attention to using the parameter method?

If you are wanting to use a Particle Parameter, You will need to use Particle Color in your material and then setup an Initial Color Module to use a Vector Parameter (drop the ColorOverLife module). The setup would be the essentially the same in Blueprints without the need to make a MID for the Particle System.

There is a great series by one of Epic’s Senior VFX Artist Tim Elek on our Wiki, I would highly recommend reading through them:

Thank You

Eric Ketchum

Thanks for the link. I’ve read those lessons before and I’ve had quick read again but just couldn’t find where I did wrong.

Would you take a look at my settings if it’s not too much trouble? I’ve put the bp event graph and the detail panel of the particle system in bp in the question and here are the particle material and the initial colour setting of my particle system.

Thank you so much!

50524-pparameterpd.png

Hi -

Your Material and Cascade Setup look correct (though I might change the Constant RGB to 1,1,1 - more for preview purposes than anything else). I don’t see your Event Graph. If you can post that for me I will take a look

Thank You

Eric Ketchum

Hi the last 2 pics in my original question post are my event graph and the detail panel of the particle system in my bp actor.

And thanks for the tip, it would indeed help with previewing, as 000 makes me wonder that my particle isn’t working at all.

Hey -

Looking again, Change all of the Param Modes to DPM_Direct from DPM_Normal.

Let me know if that doesn’t correct the issue for you -

Eric Ketchum

got the exact same problem but in c++.
using a material with only particle color as input and trying to modify the distributionvectorparameter from code after creating a particlecomponent by SpawnEmitterAtLocation.

turns out the particlecomponent doesnt react on setvectorparamter / setcolorparamter and wont give any results for getvectorparamter/getcolorparamter either.

the paramter is just not to be found within the particlecomponent. is there anything i have to call to init the params for me to edit?

In my example above, you will need to set the actual Vector Parameter name in Cascade in the Initial Color Module of your emitter stack.

50524-pparameterpd.png

Also as I noted, make sure to set the ParamType all to Direct and not Normal as shown in the image.

Eric Ketchum

I should note here as well that using Initial Color with GPU Particles is still a known issue as of 4.11 Preview 6.

However there is a workaround:

  1. Set your Initial Color Module to a
    Constant 1,1,1
  2. Add a Scale Color / Life Module
  3. In the Color Scale Over Life set the
    Distribution to Vector Particle
    Parameter
  4. Name your parameter in Parameter
    Name
  5. Under Param Modes set the 0,1 and 2
    all to DPM Direct
  6. If needed, set the Constant RGB
    values to 1,1,1 (will not affect
    outcome.)

You should now be able to control the Particle Parameter in your Blueprints. Remember you can also stack the same module more than once, so you can add another Scale Color / Life Module to control overall behavior over the particles life, if required.

I have attached a sample project below showing the setup mentioned above.

Thank You -

Eric Ketchum

Test Project 4.10.4

its working like you are describing above in the editor. in a cooked build it doesnt work for me, the color stays the same and you cant change it on runtime. futhermore its like having color over life but i really need initial Color. the born partical should get it color from a bluescript value and keep it over its lifetime.