Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Using valueAtTime expression with a position

  • Using valueAtTime expression with a position

    Posted by Craig Ricker on July 26, 2011 at 7:07 am

    Hi there,

    Basically I have a layer using the valueAtTime(time-1) expression on another layers position. I want it to only do this say from 1-5 seconds, and then I would like it to stop, so I can keyframe the position from then on. Is there a way of writing this through expressions, or must I end the layer at the 5 second mark, and start a new layer that I can keyframe that picks up from where it left off?
    Hope that made sense

    Craig Ricker replied 14 years, 9 months ago 3 Members · 5 Replies
  • 5 Replies
  • Greg Burrus

    July 26, 2011 at 4:02 pm

    I think you maybe be able to use expression timeline script https://aescripts.com/expression-timeline/. Another option would be to right a if statement to tell it to on work up to a certain frame which is essentially what the script does but automatically.

    However I’m thinking that when you switch it off the layer following may jump to the position it was at originally before it started following. So you may want to try another approach that will let it stay at it’s last position.

    hope this helps

    Greg

    https://mogra.g2bproductions.com/ – Blog
    https://g2bproductions.com/ – Portfolio

  • Dan Ebberts

    July 26, 2011 at 4:41 pm

    Something like this, probably:


    timeToStop = 5;
    if (time < timeToStop){
    (your expression goes here)
    }else{
    value
    }

    Dan

  • Craig Ricker

    July 27, 2011 at 1:59 am

    Thanks for the replies guys.

    Ok so I want to make it a little more complicated and I wonder if this is possible.
    What I would like is this.

    Object A follows object B using
    timeToStop = 6.5;
    if (time < timeToStop)
    {thisComp.layer(“Shape Layer 1”).transform.position.valueAtTime(time-1)}
    else{
    }
    At 6.5 Object A continues on, and I would like Object B to follow but I would like it to gradually (say over the next 1 second) add 5 to the x value of the position of Object B.

    So at 6.5 seconds the following would be true
    Object A position [0,0]
    Object B position [0,0]

    And at the end of that next second (7.5) the following would be true
    Object A position [5,10]
    Object B position [10,10]

    How can I go about gradually incrementing the X position of object B whilst still having it follow Object A?

  • Dan Ebberts

    July 27, 2011 at 3:31 am

    So after 6.5 seconds the follower is still following but acquires a 5-pixel x offset over one second, is that correct? If so, that could look like this:


    timeToStop = 6.5;
    if (time < timeToStop){
    thisComp.layer("Shape Layer 1").transform.position.valueAtTime(time-1)
    }else{
    xOffset = ease(time,timeToStop,timeToStop+1,0,1);
    thisComp.layer("Shape Layer 1").transform.position.valueAtTime(time-1) + [xOffset,0]
    }

    But this is simpler and does the same thing:


    timeToStop = 6.5;
    xOffset = ease(time,timeToStop,timeToStop+1,0,1);
    thisComp.layer("Shape Layer 1").transform.position.valueAtTime(time-1) + [xOffset,0]

    Dan

  • Craig Ricker

    July 27, 2011 at 6:31 am

    Brilliant! Learning heaps, thanks!

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