Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Posted by Alex Weil on June 7, 2018 at 3:05 pm

    hey,
    is it possible to move an layer if something happens, for example, when my solid is higher than wide, layer 2 should move from p1 to p2 and vice versa. i coded something like that, but its not moving on the event.

    w=thisComp.layer("Black Solid 1").width/100*thisComp.layer("Black Solid 1").transform.scale[0];
    h=thisComp.layer("Black Solid 1").height/100*thisComp.layer("Black Solid 1").transform.scale[1];

    if (h < w) {
    linear(time,key(1),key(2));
    } else {
    linear(time,key(2),key(1));
    }

    Kalleheikki Kannisto replied 7 years, 11 months ago 2 Members · 1 Reply
  • 1 Reply
  • Kalleheikki Kannisto

    June 8, 2018 at 1:52 pm

    From the looks of it you’re attempting to apply the expression to time remapping. That could be done, I guess, but it would make more sense to apply an expression to the layer position.

    What the problem with your current expression is, is that the linear expression is trying to remap the first second of time (0-1) on the timeline to a “range” between two keyframe objects, which basically doesn’t make much sense.

    Now, since expressions are not aware of time, you need a loop to check backwards (or forwards or both) from the current frame for past and future values, frame by frame.

    For instance, in order to find out how many frames ago the value changed from H>W to H

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