Skip to main content
Participant
Jun 27, 2024 12:58 PM UTC
Answered

Problems with animated text using sourceRectAtTime

Hello, Im doing an animated text inside a Rectangle.
The animation is like the "Typewriter" template, but instead of opacity I used scale 0%

 

The animation works great if i play it from frame 0, but if i grab the Text and Rectangle layer and move to the frame 100, the Rectangle is already in full size when my text is empty. 

Is like the size of my text is being read from the layer timeline, instead of the composition timeline.

Expression im using in my Rectangle

x = thisComp.layer("text").sourceRectAtTime().width;
y = thisComp.layer("text").sourceRectAtTime().height;

[x,y]

This topic is closed to new replies. Start a new post to keep the conversation going.
Dan Ebberts
Dan EbbertsCorrect answer
Community Expert
Jun 27, 2024 1:45 PM UTC

sourceRectAtTime() has a built-in time parameter, so I think you just need to do something like this:

L = thisComp.layer("text");
x = L.sourceRectAtTime(time - L.inPoint).width;
y = L.sourceRectAtTime(time - L.inPoint).height;
[x,y]

4 replies

Community Expert
Jun 27, 2024 8:06 PM UTC

If you are using a text animator or scale, you will have to throw in a multiplier for Position to keep the rectangle lined up because the rectangle size will grow using Dan's expression, but it will not be offset. You will have to take sourceRectAtTime(when the text is fully revealed) and create a linear interpolation method that adjusts the Rectangle 1/Position so the box expands from the left side of the text instead of the middle. You still may have a problem with the rectangle jumping around because the text scales from the middle. I don't have time to fiddle with it right now, but I have created similar things in the past and ended up relying on a simple expression that uses the size of the text at the last keyframe and a simple linear interpolation between the first and last keyframes. 

 

 

Translate
Participant
Jun 28, 2024 9:59 AM UTC

Luckily i have the text aligned to the side, and in the Rectangle i have the following Expression in position

content("BOX").content("Rectangle Path 1").size/2

Translate
Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
Jun 27, 2024 1:45 PM UTC

sourceRectAtTime() has a built-in time parameter, so I think you just need to do something like this:

L = thisComp.layer("text");
x = L.sourceRectAtTime(time - L.inPoint).width;
y = L.sourceRectAtTime(time - L.inPoint).height;
[x,y]
Translate
Participant
Jun 28, 2024 9:57 AM UTC

*chef kiss* works perfectly thanks 😄

Translate