Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions If statement doesn’t work in expression

  • If statement doesn’t work in expression

    Posted by Viktor Synkov on March 23, 2017 at 4:26 pm

    I’m trying to make clouds move out of frame and than appear again from the other side.

    First time if statement works as expected. tBound becomes 40s and it offsets cloud. But when time gets bigger than 40 nothing happens. Neither offset variable gets bigger nor tBound. If statement doesn’t work anymore. What’s the problem here?

    var vel = 100;
    var pInit = position.valueAtTime(0)[0]; // initial position of a cloud
    var tInit = (thisComp.width-pInit)/vel; // time it takes to cross the right border starting from init position
    var tFull = (thisComp.width+width)/vel; // time it takes to cross the frame starting behind the left border
    var offset = 0;
    tBound = tInit;

    if(time > tBound) {
    tBound += tFull;
    offset += thisComp.width+width;
    }

    [value[0]+time*vel-offset,value[1]]

    Lars Jandel replied 9 years, 1 month ago 3 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    March 23, 2017 at 6:48 pm

    It looks like you may be assuming an expression will remember values from previous frames. It won’t. What is it you’re trying to do?

    Dan

  • Lars Jandel

    March 23, 2017 at 8:14 pm

    Couldn’t you use just the “Motion Tile” animation preset and animate the tile center’s x-axis? You could easily put an expression on that property and change the speed.
    Just an idea for a simple solution… ????

    Cheers, Lars.

    x = time*100;
    y = effect("Motion Tile")("Tile Center")[1];
    [x, y]

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