Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Value at Time expression

  • Value at Time expression

    Posted by Tristan Nieto on November 21, 2008 at 4:12 pm

    Hi all,

    Is there an expression I can use to resolve this? What I have is an object (A) that needs to be in a certain position when another object (B) arrives at another position. However, the thing that makes it difficult is that the magic position that B needs to be in isn’t fixed in time or space, but is what ever position it happens to be in when it’s opacity reaches zero.

    Put another way, I need an expression that can tell me what the position of object B will be when it is at 0% Opacity, without knowing when on the timeline that’s going to happen. Is there a way to write this?

    Thanks,
    Tristan

    Ido Shor replied 9 years, 7 months ago 5 Members · 5 Replies
  • 5 Replies
  • Darby Edelen

    November 21, 2008 at 5:39 pm

    I’m not sure that I have enough information to give you a satisfactory answer. Do you want object B to just immediately appear at a certain position when object A’s opacity is 0%? Do you want it to animate from one position to another as object A’s opacity goes from 100% to 0%?

    I’m guessing the latter, but it’s really hard to tell exactly how you want object B to behave based on object A’s opacity.

    Do you need object B to follow a motion path to get where it needs to be or should it move linearly?

    Darby Edelen

  • Dan Ebberts

    November 21, 2008 at 7:35 pm

    This should cause layer B to jump to layer A’s position when layer A’s opacity hits zero. But as Darby points out, jumping might not be what you want.

    A = thisComp.layer(“A”);

    f = 0;
    foundIt = false;
    while (f <= timeToFrames()){ if (A.transform.opacity.valueAtTime(framesToTime(f)) == 0){ foundIt = true; break; } f++ } if (foundIt){ A.transform.position.valueAtTime(framesToTime(f)); }else{ value; } Dan

  • Brendan Mccullough

    November 21, 2008 at 10:08 pm

    This is a question I’ve found myself asking lately too. How does one change values at a specified time, but using a smooth animation, rather than a drastic jump. I’ve been noodling it, and I’m sure it’s something like:

    if(time >= someValue) {
    linear(time, time, time+animationDurationInFrames, value01, value02);
    }

    but I can’t quite grasp what I’m missing.

    I was playing with a rotation value today that it would have been nice to have this. I want to rotate between (let’s just say) 0 degrees and 10 degrees over the course of 10 seconds, and then, in 30 frames, I want to complete the rotation back to 0 degrees from 10 degrees, and then continue the move from 0 degrees to 10 degrees over the course of the next 10 seconds.

    My gut tells me there’s a modulus equation that’ll get me what I want, but yet again, it’s eluding me. It’d be something like…

    duration = 300;
    if(duration % 300 == 0) smoothly animate expression that’s probably linear(something);

  • Darby Edelen

    November 22, 2008 at 9:22 pm

    The most robust method I can think of would be accessing the value of the property that will drive the animation (in this case opacity) and then updating the position of the current layer along its motion path based on that value:


    if(numKeys > 1){
    k1 = key(1).time;
    k2 = key(numKeys).time;
    o = thisComp.layer("Opacity_Layer").opacity;

    linear(o, 100, 0, valueAtTime(k1), valueAtTime(k2));
    }
    else value;

    I haven’t tested it, but something like the above should work if applied to a position property.

    Darby Edelen

  • Ido Shor

    September 13, 2016 at 9:10 am

    I tried implementing this expression to my comp, but it seems to be very hard for my machine to compute.

    any suggestion why might that be?
    can it be because the value of my “A” is driven from a random slider?

    shame, cause this expression is a keeper.

    thanks, Ido.

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