0 like 0 dislike
86 views
Hey,

I'm looking to adjust the Flux Function Tiled Relative Duration at runtime in Unity based on user input. Essentially, I plan on tying the FFTRD to a slider so that the User can control how long the system spawns for via attributes. However, I can't seem to access the FFTRD via scripting. another method I've tried is through LayerScripts and the "Life" function, but apparently "Life" is currently read only at the moment as stated here:

http://wiki.popcornfx.com/index.php/Scripting_reference_190#Layer_scripts

Any comments or assistance would be appreciated, thanks!
by Jbaautista (140 points)

1 Answer

0 like 0 dislike

Hi,

FluxFunctionTiledRelativeDuration isn't tweakable at runtime. However, it is possible to assign FluxFactorExpression to an attribute value, that you can tweak at runtime.

If it is specifically FluxFunctionTiledRelativeDuration that you want to tweak at runtime, it is probably because you want to use a tiled flux function curve. You could fake it:

  • Create a curve sampler, say Curve_0, representing your layer's untiled flux
  • Create a "MyFFTRD" Float1 attribute
  • Create a layer script on your layer(s)
Simple approach:
function void Run()
{
    Flux = Curve_0.sample(frac(Age * MyFFTRD));
}
However, this approach could miss tiny pikes in your curve sampler when you have a big MyFFTRD or a low framerate. If you want to have more informations, see this link. You can replace this LayerScript by the following one, which is more complex, but fully accurate:

function void Run()
{
    float t0A = Age - dt;
    float t1A = Age;
    float t0 = frac(t0A * MyFFTRD);
    float t1 = frac(t1A * MyFFTRD);

 

    float fA = Curve_0.integrate(t0, 1) + Curve_0.integrate(0, t1);
    float fB = Curve_0.integrate(t0, t1);

 

    Flux = iif(t0 > t1, fA, fB) / dt;
}

Hope this helps.

by HugoPKFX (16.8k points)
...