Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Opacity semi-random issue

  • Opacity semi-random issue

    Posted by Trevor Navarre on January 15, 2018 at 8:59 pm

    I have a displacement map I would like to flicker on and off randomly, however I would like it to be off more that on and only be on a few times rather than a majority.

    Here’s what I came up with :

    random(0,100);
    if (thisComp.layer(“displace”).transform.opacity < 90) 0 else 100;

    It doesnt seem to randomize once I put all of this in…. any help would be appreciated. Also if there is a way that when it does switch “on” it stays on for maybe 10 frames I’d appreciate a hint on that! Thanks in advance for any help!

    random(0,100);
    if (thisComp.layer("displace").transform.opacity &lt; 90) 0 else 100;

    Kevin Camp replied 8 years, 6 months ago 2 Members · 4 Replies
  • 4 Replies
  • Kevin Camp

    January 15, 2018 at 9:13 pm

    you’re close… you just need to assign the random value to a variable and compare that variable to 90 to set the opacity….

    r = random( 0, 100 ) ;
    if ( r < 90 ) 0 else 100 ;

    note, if the less than sign gets replaced with < manually replace it with the symbol.

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • Trevor Navarre

    January 15, 2018 at 9:20 pm

    Thanks! Seems to be working!

  • Trevor Navarre

    January 15, 2018 at 10:49 pm

    This is kind of primative but below is what I’m trying to do but just unable to articulate. Any clue?

    r = random( 0, 100 ) ;
    if ( r &lt; 90 ) 0 else 100 ;
    if (r = 100) (r = 100 for 8 frames)

  • Kevin Camp

    January 16, 2018 at 6:32 pm

    you could try using posterizeTime() to have a new random value generated every 8 frames (instead of every frame):

    hold = 8 ; // value in frames
    fps = 1 / thisComp.frameDuration / hold ;
    posterizeTime( fps ) ;
    r = random( 0, 100 ) ;
    if ( r < 90 ) 0 else 100 ;

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

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