Only enabling expressions on certain keyframes

New Here ,
Aug 18, 2020

Copy link to clipboard

Copied

I'm setting up an opening title that needs to have a constantly changing title. I have used an expression to create a dynamic text box which is all fine and dandy. However, the next step is where it becomes out of my depth. In the video at the moment is a half circle which at the end of the animation lines up with the dynamic text box, using the following expression:
gap=20;

L = thisComp.layer("TEXT");

rect=L.sourceRectAtTime(time,false);

x=L.toComp([rect.left,0])[0];

[x-gap,value[1]]

My question is can I "keyframe" the value this expression gives at the end of the animation but keyframe earlier so that the half circle begins in the middle of the comp. Possibly is there a way to make the above expression linked to slider at value="100" and then not linked at value="0".

Any suggestions would be greatly appreciated.

Most Valuable Participant
Correct answer by Mylenium | Most Valuable Participant

You have a fundamental misunderstanding here. There is basically no requirement to turn anything on or off nor would that be in any way advisable, given how AE evaluates expressions. The expression already holds the last value for you and keeping things centered would be merely a case of adding an interpolator that can be controlled with a slider (pseudo-code):

 

 

linear(slider,0,100,value[0],x-gap)

 

 

No need to make it more complicated than that and using this method will ensure consistent results. On a more general level you might also want to study up on evaluation order in AE. It's always property base value -- > keyframes --> expressions, so the proper way to "disable" an expression is simply to use multipliers and such to zero out the expression result and only leave the keyframe or property base value. That's basically what the simple linear() interpolator in my example does.

 

Mylenium

TOPICS
Expressions, How to

Views

45

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Only enabling expressions on certain keyframes

New Here ,
Aug 18, 2020

Copy link to clipboard

Copied

I'm setting up an opening title that needs to have a constantly changing title. I have used an expression to create a dynamic text box which is all fine and dandy. However, the next step is where it becomes out of my depth. In the video at the moment is a half circle which at the end of the animation lines up with the dynamic text box, using the following expression:
gap=20;

L = thisComp.layer("TEXT");

rect=L.sourceRectAtTime(time,false);

x=L.toComp([rect.left,0])[0];

[x-gap,value[1]]

My question is can I "keyframe" the value this expression gives at the end of the animation but keyframe earlier so that the half circle begins in the middle of the comp. Possibly is there a way to make the above expression linked to slider at value="100" and then not linked at value="0".

Any suggestions would be greatly appreciated.

Most Valuable Participant
Correct answer by Mylenium | Most Valuable Participant

You have a fundamental misunderstanding here. There is basically no requirement to turn anything on or off nor would that be in any way advisable, given how AE evaluates expressions. The expression already holds the last value for you and keeping things centered would be merely a case of adding an interpolator that can be controlled with a slider (pseudo-code):

 

 

linear(slider,0,100,value[0],x-gap)

 

 

No need to make it more complicated than that and using this method will ensure consistent results. On a more general level you might also want to study up on evaluation order in AE. It's always property base value -- > keyframes --> expressions, so the proper way to "disable" an expression is simply to use multipliers and such to zero out the expression result and only leave the keyframe or property base value. That's basically what the simple linear() interpolator in my example does.

 

Mylenium

TOPICS
Expressions, How to

Views

46

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 18, 2020 0
New Here ,
Aug 18, 2020

Copy link to clipboard

Copied

I also forgot to add that I need to replicate the same thing to happen on the logo so that the logo is always a certain distance to the left of the text box, but still keeps the logo and text box centered.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 18, 2020 0
Guide ,
Aug 18, 2020

Copy link to clipboard

Copied

As usual, there are many ways to solve this. 

 

My approch would be to stick the half-cicle on the left side of the text box with an expression and use an animation to hide/reveal it (like x-scale from 0 to 100 and opacity from 0 to 100 for one frame to make sure it isn't visible at 0 x-scale).

 

You are already doing it with the text-box itself.

 

 

Generally, you can use an if-else-condition to switch on/off expressions.

 

For example, this will start a wiggle after 1 sec and keep the wiggle for ever.

 

if (time >= 1){

        wiggle(20,20);

} else {

        value;

};

 

You can do this in combination with a slider (and all other stuff) aswell. Instead of time, use the slider value:

 

slider = *drag slider here*

if (slider == 100){...};

 

You can also read out a certain keyframe time and use this as trigger:

 

key = thisProperty.key(1).time;       // time of first key

if (time > key){...}                          // do the code after passing the key

if (time > key+1){...}                      // do the code after passing the key + 1 second

 

 

Hope this brings you further.

 

*Martin

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 18, 2020 0
New Here ,
Aug 18, 2020

Copy link to clipboard

Copied

Thankyou for your help, this didn't help with this specific project but it certainly just helped me learn some things.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 18, 2020 0
Most Valuable Participant ,
Aug 18, 2020

Copy link to clipboard

Copied

You have a fundamental misunderstanding here. There is basically no requirement to turn anything on or off nor would that be in any way advisable, given how AE evaluates expressions. The expression already holds the last value for you and keeping things centered would be merely a case of adding an interpolator that can be controlled with a slider (pseudo-code):

 

 

linear(slider,0,100,value[0],x-gap)

 

 

No need to make it more complicated than that and using this method will ensure consistent results. On a more general level you might also want to study up on evaluation order in AE. It's always property base value -- > keyframes --> expressions, so the proper way to "disable" an expression is simply to use multipliers and such to zero out the expression result and only leave the keyframe or property base value. That's basically what the simple linear() interpolator in my example does.

 

Mylenium

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 18, 2020 0
Matt4822 LATEST
New Here ,
Aug 18, 2020

Copy link to clipboard

Copied

Thankyou for your assistance! This is exactly what I needed

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 18, 2020 0