Activity › Forums › Adobe After Effects Expressions › sourcerectattime not working for a specific time
-
sourcerectattime not working for a specific time
-
Adam Greenberg
May 6, 2021 at 6:14 pmHi, I have an expression that is working perfectly except for the fact that my title is animated in at the beginning ( in scale, position, and blur ). I thought I correctly identified the time to be 2 seconds so that any animation before or after would be disregarded, but its not working. I cannot figure out my error. Thanks for any help.
Adam
L = thisComp.layer(“TITLE”);
M = thisComp.layer(“DATE”);
rect = L.sourceRectAtTime(2,true);
rv = M.sourceRectAtTime(2,true);
x = L.toComp([rect.left+rect.width,0])[0];
y = M.toComp([rv.left+rv.width,0])[0];
xclamp=clamp(x,545.70,2000);
yclamp=clamp(y,545.70,2000);
if (x>y) xclamp+gap;
else yclamp+gap
-
Andrei Popa
May 7, 2021 at 6:49 amTry to use rect = L.sourceRectAtTime(L.sourceTime(2),true); I had the same problem if the layer was moved forward or backward in the timeline.
-
Adam Greenberg
May 7, 2021 at 3:52 pmI tested something. I added a new variable s with
S=thisComp.layer(“test”).marker.key(“1”).time;
I Tested the value at s and it is constant.
but when I replace 2 with s in the expression, it still doesn’t work. It’s still animating the value. So the problem must be the way L is defined. Can I make L look at the title layer but only at a specific time. I tried to write it and rewrite it and I cannot figure it out.
There must be a way for me to define L as this comp layer title but only at time s.
Thanks.
-
Tomas Bumbulevičius
May 7, 2021 at 5:01 pmJust an idea – see if inPoint of a layer you are timing to, matches the start time of composition. If not – try to take that difference into account .
-
Adam Greenberg
May 7, 2021 at 5:22 pmI was thinking that also, until I replaced 2 with 200 and got the exact same result which means the time part of my expression is not affecting it at all.
I can only guess that the definition of L needs a fixed time associated with it because even thought rect is well defined, the L must be looking at the text layer at every frame. It’s so frustrating knowing that the logic is there but I’m missing a command that I dont yet understand. some sort of value at time. I guess in the meantime I will duplicate my text layers, mute them, expression them to the source text of the real layers, remove all key frames from them, and add a correction slider in case one day a user goes in and plays with the character settings of that layer which would change the math a little.
-
Dan Ebberts
May 8, 2021 at 12:19 amAnimating the position or scale shouldn’t affect sourceRectAtTime(). What will affect your result though, is the time parameter of toComp(). See if doing it this way helps:
x = L.toComp([rect.left+rect.width,0],2)[0];
and
y = M.toComp([rv.left+rv.width,0],2)[0];
-
Adam Greenberg
May 10, 2021 at 2:07 pmThanks so much Dan. I had no idea there was a time parameter in the tocomp. Makes total sense once you know that, and impossible to solve if you don’t.
Have a great week. Thanks again.
Reply to this Discussion! Login or Sign Up
Log in to reply.