0 like 0 dislike
92 views
Is there a way to bring in the Delay field within the spawn base into the customizable code? I want to be able to have it be effected by an attribute and I can't seem to find any literature about it.
asked by Jbaautista (140 points)

1 Answer

0 like 0 dislike

You can't customize the 'Delay' property directly, but you can change the layer emission rate coefficient (which we call 'Flux').

 

To change this, you have two ways:

1- First way is to just create a 'float' attribute, and type the attribute name in the "FluxFactorExpression" property (which is at the bottom of the layer's property list)

the layer will then use the attribute as a spawn-rate multiplier.

Don't get fooled by the "Expression" part in "FluxFactorExpression", you can't actually type an expression with math operations and all, you can just type something like "MyAttribute.z" if the attribute you want to use is not of type 'float', that's all.

You can read more details about this on the wiki here: http://wiki.popcornfx.com/index.php/Particle_tips_FluxFactorExpression (pretty old page, made with popcorn editor v1.4.0, but still applies to the current versions)

You can still use more complicated expressions to set the Flux though, which brings us to option 2:

 

2 - The other way is to use a layer-script, where you can use an attribute, a sampler, scene raycast queries, etc...

To create a layer script, right click on your layer, and select 'New Layer Script' in the contextual menu:

Then click on the new LayerScript node to bring in the script editor:

Here, I created a new 'SpawnFactor' attribute that's used to set the 'Flux' property:

 

So, with this simple setup, when the attribute is zero, the layer won't spawn any particle. when the attribute is 0.5, it will spawn at half the rate defined in the layer properties, when set to 1, it will spawn at full rate.

If you change the default attribute properties and make its 'max' value, say, 10, and you set it to 10, the layer will spawn 10 times more particles than what's defined in its properties.

Of course you can use anything available in scripts to compute this 'Flux' property.
combine multiple attributes, compute the emitter's world velocity, whatever...

To see the layer properties you can access from the layer script, you can take a look at this page:

v1.9.0: http://wiki.popcornfx.com/index.php/Scripting_reference#Layer_scripts
v1.8.x: http://wiki.popcornfx.com/index.php/Scripting_reference_180#Layer_scripts

 

Note that if you're using the layer script just to ram the attribute directly into 'Flux' without modifying it, it'll be more efficient for the runtime if you just use option 1 mentioned above, and use the "FluxFactorExpression" instead of a layer script.

 

answered by Julien (32.2k points)
...