Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions I need to change the layer position randomly every some seconds.

  • I need to change the layer position randomly every some seconds.

    Posted by Taha Arrabe on December 27, 2021 at 9:35 pm

    Hi,
    I have a simple icon layer.
    I need to change the icon position randomly every some seconds;
    But, every time the icon changes its position, I need the icon’s opacity to start from 0 to 100.
    after the icon’s opacity reach 100 I need it to stay in the same position for some seconds;
    then change its position again.
    I will make two sliders for this expression
    one to control the time that the icon needs to reach the opacity 100 after its appearance.
    and one to control the time that the icon will stay in its position after its reaches opacity 100.
    How to do this?

    Taha Arrabe replied 4 years, 4 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    December 27, 2021 at 9:51 pm

    <div>Maybe something like this for position:</div>

    fade = effect("Fade Time")("Slider");
    hold = effect("Hold Time")("Slider");
    upperLeft = [50,50];
    lowerRight = [thisComp.width-50,thisComp.height-50];
    period = fade + hold;
    seed = Math.floor((time - inPoint)/period);
    seedRandom(seed,true);
    random(upperLeft,lowerRight);

    and something like this for opacity:

    fade = effect("Fade Time")("Slider");
    hold = effect("Hold Time")("Slider");
    period = fade + hold;
    t = (time - inPoint)%period;
    linear(t,0,fade,0,100

    Adjust upperLeft and lowerRight in the position expression to define the rectangular random area.

  • Taha Arrabe

    December 28, 2021 at 9:13 am

    Thank You.
    it worked perfectly.
    I didn’t expect that it can be done without the “for” or “while” loops.
    using the time in the “seedRandom” seed is an excellent trick.
    PEACE

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