Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random Lightining Strikes

  • Random Lightining Strikes

    Posted by Pat Bray on June 18, 2011 at 12:14 pm

    Hi

    I was hoping to create lightning strikes from one element and wondered if there was a way to write an expression so when that element’s opacity = 0% it would reposition randomly , say 20-30 pixels? (the lightning is flickering using a simple wiggle expression at the moment).

    Any suggestions?

    Pat Bray replied 14 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    June 18, 2011 at 4:48 pm

    This should give you a new random position every time the opacity goes below 1%:


    p = transform.opacity;
    threshold = 1;
    trig = false;
    for (f = timeToFrames(); f >= timeToFrames(inPoint); f--){
    tCur = framesToTime(f);
    v = p.valueAtTime(tCur);
    if (trig && (v > threshold)) break;
    if (v <= threshold) trig = true;
    }
    seedRandom(f,true);
    offset = random([-20,-20],[20,20])
    value + offset

    Dan

  • Pat Bray

    June 21, 2011 at 9:09 am

    Thank you! Wish I knew expression coding more thoroughly, it’s such a time saver and my workflow is so much tidier, unlike my desk… 😛

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