Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions linear, time expression

  • linear, time expression

    Posted by Dmytro Baranov on January 14, 2024 at 12:08 am

    Hi all! Can you please advise if it’s possible to adjust something in the expression? The code is simplified.

    t = transform.yPosition;

    if (a > b) {

    t = linear(time, 0, 3, value, value);



    I need the position to smoothly transition to another, and this seems like a working approach. The issue is that I need the animation conditions to start immediately after becoming true. Currently, it runs from 0 to 3 seconds. Is there a way to tie the animation to the condition so that it starts from the beginning?

    Meaning something like this

    t = transform.yPosition;

    if (a > b) {

    t = linear(time,”a > b = true”, “a > b+3 sec”, value, value);



    Dmytro Baranov replied 3 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    January 14, 2024 at 12:38 am

    Not directly. Expressions have no memory, so when an expression wakes up, it has no way of knowing if it’s in the middle of an animation that was triggered in the past. It has to either (depending on what kind of triggering you want) go backwards from the current frame, or forwards from time=0, frame-by-frame (using valueAtTime) to figure out if a triggering event has occurred, and if so, how long ago did it happen. It’s a little tricky, but not too tough to set up. You have to decide whether it’s looking for a single trigger event, or if it can be re-triggered. So, more details about how it should actually work would be helpful.

  • Dmytro Baranov

    January 14, 2024 at 5:39 pm

    Thanks for reply. I tried to rewrite it, but it didn’t work, probably still not right. I tried to show on the video what I need.

    var x = thisComp.layer(“Data_02”).effect(“Point Control”)(“Point”)[0];

    var y = thisComp.layer(“Data_01”).effect(“Point Control”)(“Point”)[0];

    var isTriggered = x < y;

    var modifiedTime = time + isTriggered;

    if (isTriggered) {

    var animationDuration = 5;

    var startTime = Math.floor(modifiedTime / animationDuration) * animationDuration;

    var endTime = startTime + animationDuration;

    t = linear(modifiedTime, startTime, endTime, value, thisComp.layer(“Line_01”).transform.yPosition);

    } else {

    t = value;



  • Dan Ebberts

    January 14, 2024 at 10:20 pm

    I’m not 100% sure, but this might be close to what you’re looking for:

    x = thisComp.layer("Data_02").effect("Point Control")("Point");
    y = thisComp.layer("Data_01").effect("Point Control")("Point");
    t = 0;
    for (f = 0; f <= timeToFrames(time); f++){
    tf = framesToTime(f);
    if (x.valueAtTime(tf)[0] < y.valueAtTime(tf)[0]){
    t = time - tf;

  • Dmytro Baranov

    January 15, 2024 at 6:10 am

    Unfortunately, the animation starts from the very beginning and not when the condition is true.

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