Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions sourceRectAtTime() not updating when I move the layer on the timeline

  • sourceRectAtTime() not updating when I move the layer on the timeline

  • Andrei Popa

    September 16, 2020 at 1:19 pm

    HI everyone. I stumbled on something that I think it’s a bug and I really need for it to work.

    The situation is this.

    I draw a rectangle. And then add this expression to the anchorpoint.

    var myWidth = sourceRectAtTime(time,false).width;
    var left = sourceRectAtTime(time,false).left;
    var myHeight = sourceRectAtTime(time,false).height;
    var top = sourceRectAtTime(time,false).top;
    [left+myWidth,myHeight/2+top]

    This takes my anchorpoint to the right part of the rectangle. If I change the size of the rectangle(not the scale), the anchorpoint follows as it should.

    But if now I move my shape layer 2 seconds before, the anchorpoint expression does not work as it should. It has a delay of 2 seconds, like I never moved the layer. Even if I add some keyframes to the size again, the anchorpoint is 2 seconds later for those 2 keyframes too.

    I tried removing the expression and then pasting it again. Purging the cache. Enable/disable expression. Adding/removing keyframes.

    If anyone had the same issue and found a solution please tell.

    Thanks.

  • Dan Ebberts

    September 16, 2020 at 1:52 pm

    Andrei,

    I’m not understanding what you mean by this:

    >But if now I move my shape layer 2 seconds before

  • Filip Vandueren

    September 16, 2020 at 6:31 pm

    Hey Andrei, sourceRectAtTime refers to the source’s time, which – if you’ve (accidentally) changed the inPoint of the layer – is not necessarliy in sync with the composition’s time.

    So the safest and correct use is:

    l.sourceRectAtTime(time-l.startTime);

  • Andrei Popa

    September 17, 2020 at 5:56 am

    I got the correct answer from this post

    https://community.adobe.com/t5/after-effects/sourcerectattime-and-text-animation-unsync/td-p/10751331?page=1

    But when I tried to post the answer here I received a restriction because the forum thought it was spam.

    Apparently, sourceRectAtTime() is not in sync with comp time. I used sourceTime() instead of time. And when referring to another layer’s sourceRectAtTime(), you have to address that layer’s sourceTime().

    Like this. You can put any number you need as the sourceTime() argument. Now if I change the placement of my layer in the time line, the expression updates to the new time.

    L = thisComp.layer("Test");
    R = L.sourceRectAtTime(L.sourceTime(inPoint),false);

    Thank you both for answering.

  • Filip Vandueren

    September 18, 2020 at 11:01 am

    Yes, an even more robust way! This will also account for stretched or reversed layers etc.

Viewing 1 - 5 of 5 posts

Log in to reply.

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