0 like 0 dislike

Hi , 

Is it possible to publish the "DurationInSeconds" from the CActionFactoryParticleSpawnerBase from  in the ParticleEffect Attribute in the V1.12?

Thank you

by mtakerkart (200 points)

1 Answer

1 like 0 dislike


This is possible by using a Layer Script.

Simply create a ParticleEffect Attribute of type float and use it to set the value of the Life field in the Layer Script.

If your layer don't have a Layer Script, right click on it in the TreeView and select "New Layer Script".

In the layer script, input the following: "Life = MyDurationAttribute;" where you replace "MyDurationAttribute" by the name of your attribute.

Hope this helps.

by tdesveauxPKFX (160 points)
I'm not talking about the life of particle. I'm talking about the DurationInSeconds of the spawner in the General Tab. See the screen shot here:
Yes, that's why you'll need a layer script and not a regular particle script.

Layer scripts allow you to control _some_ of the layer properties. Writing to "Life" in the layerscript changes the layer duration.
You can also write to "Flux" to change the spawn rate based on an attribute, a sampler, etc.

See this section of the scripting reference to see what you can read and write from layer scripts: https://wiki.popcornfx.com/index.php?title=Scripting_reference_1130#Layer_scripts

The properties you can write are tagged with "RW"
Ok thank you for your answer. Unfortunately it doesn't work with the 1.12 version , it works with the 1.13. It's for an Iclone project wich is stucked on the 1.12 version....
Damn !
Indeed "Life" wasn't writeable for layers in v1.12...

OK so there are 2 workarounds you can use. Either:

1- make the layer infinite and turn off "Flux" in the layerscript when it's older than the life attribute: "Flux = select(1, 0, Life > MyAttribute);". I don't know how the Iclone integration handles infinite effects, but you might need to stop the effect instance explicitly from iclone, otherwise the layer will still be simulated for doing nothing even after it stops emitting, and it'll eat some performance for no reason.


2- Use a trail evolver to fake a layer. Make your layer emit a single particle that will act as a new "layer", set the life of that particle to your attribute, add a localspace evolver, and then a trail evolver with a time metric setup to mimic the emission rate you would have set inside your original layer.

If this isn't clear I'll make a more detailed step by step reply, but it'll take some time.