Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random Motion only when opacity >= 20

  • Random Motion only when opacity >= 20

    Posted by Mauro Carlieri on January 6, 2017 at 4:02 pm

    Hi there,

    I have a light, which intensity is linked to audio track (via soundkeys)
    I need the light to random change position (only x and Y) everytime the intensity is >=30.

    I am trying with no success ☹

    PLEASE HELP…

    Dan Ebberts replied 9 years, 4 months ago 2 Members · 4 Replies
  • 4 Replies
  • Mauro Carlieri

    January 6, 2017 at 4:05 pm

    I need something like dan ebberts expression :

    holdTime = .5; //time to hold each position (seconds)
    minVal = [0.1*thisComp.width, 0.1*thisComp.height];
    maxVal = [0.9*thisComp.width, 0.9*thisComp.height];

    seed = Math.floor(time/holdTime);
    seedRandom(seed,true);
    random(minVal,maxVal)

    but instead of evry .5 sec, evrytime light intensity is >= 20

  • Dan Ebberts

    January 6, 2017 at 7:23 pm

    It’s not at all clear (to me at least) what you’re asking for. Does the layer move to a new random position every time the opacity goes from below 20 to above 20, or is it something else?

    Dan

  • Mauro Carlieri

    January 7, 2017 at 1:43 am

    Yes, exactly.
    I need the light layer to move to a new random position(only X and Y) everytime the light intensity is <=20. It must hold that position until the light intensity goes under 20 again..
    i hope is clean now.. Thanks ????????
    Mauro

  • Dan Ebberts

    January 7, 2017 at 6:03 am

    Something like this maybe:


    P = lightOption.intensity;
    threshold = 20;
    trig = false;
    for (f = timeToFrames(time); f >= 0; f--){
    tCur = framesToTime(f);
    v = P.valueAtTime(tCur);
    if (trig && (v > threshold)) break;
    if (v <= threshold) trig = true;
    }
    t = trig ? framesToTime(f+1) : 0;
    seedRandom(t,true);
    minVal = [0.1*thisComp.width, 0.1*thisComp.height];
    maxVal = [0.9*thisComp.width, 0.9*thisComp.height];
    xy = random(minVal,maxVal);
    [xy[0],xy[1],value[2]]

    Dan

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy