Activity › Forums › Adobe After Effects Expressions › How to freeze an expression at a specific time
-
How to freeze an expression at a specific time
Posted by Francesco Bona on August 21, 2018 at 1:31 pmHi I read some posts similar to this but I’m still a bit confused.
How can I freeze an expression at a specific time or frame to keep all properties it controls locked in the exact state they were at that specific moment?I did a test with a simple “wiggle”expression applied to an object position but I did not get what I wanted.
At the specified time (frame number 100) I get the original object position as if it was not controlled by the wiggle expression.
What I wanted instead was to freeze the object position as it was at frame 100.
I don’t want to simply desable the expression at frame 100, I want to freeze the expression at frame 100.
And I can’t precomposeI used this expression:
w=wiggle(5,100);
stop = 50;
timecode=timeToFrames(time);
prestop=50;if (timecode < stop){
w;
}else{
valueAtTime(prestop);
}What did I do wrong?
Thanx!!!Francesco Bona replied 7 years, 9 months ago 3 Members · 18 Replies -
18 Replies
-
Dan Ebberts
August 21, 2018 at 3:35 pmTry this:
stop = 50;
t = Math.min(time,framesToTime(stop));
wiggle(5,100,1,.5,t)Dan
-
Francesco Bona
August 21, 2018 at 4:28 pmWow!! Much more synthetic and functional! Thanks so much!
But now I undertand I need to do one more question.. I’m sorry ..I used “wiggle” as an easy expression example hoping to adapt your suggestions to my real and bigger problem.
My real intent was to understand how to freeze at a specific time any expression..This is my real mission: freezing at a specific time this expression that keeps a shape linked to the bottom margin of another shape even if its scale is changing…
a=thisComp.layer("01"); // Key object
d=30; // Distance
s=a.transform.scale[1];
apos=a.transform.position[1];
ah=a.sourceRectAtTime(time).height/2;
s1=transform.scale[1];
h=thisLayer.sourceRectAtTime(time).height/2;[180 , apos+(ah*s/100)+(h*s1/100)+d]
How can I freeze this expression for example at frame 50? I don’t understand how to use “Math.min”
Thanks again….. -
Dan Ebberts
August 21, 2018 at 4:48 pmMaybe like this:
stop = 50;
t = Math.min(time,framesToTime(stop));
a=thisComp.layer(“01”); // Key object
d=30; // Distance
s=a.transform.scale.valueAtTime(t)[1];
apos=a.transform.position.valueAtTime(t)[1];
ah=a.sourceRectAtTime(t).height/2;
s1=transform.scale.valueAtTime(t)[1];
h=thisLayer.sourceRectAtTime(t).height/2;[180 , apos+(ah*s/100)+(h*s1/100)+d]
Dan
-
Francesco Bona
August 21, 2018 at 11:08 pmI’m sorry but It doesn’t seem to work …
The expression continues to operate even after frame 50 and keeps the second object anchored to the bottom of the first.
What I need instead is the second object to remains frozen in the position it has at frame 50 even if the first object continues to move. -
Dan Ebberts
August 22, 2018 at 6:49 amIt works for me (freezes at frame 50). Clearly I must have things set up differently than you do.
Dan
-
Francesco Bona
August 22, 2018 at 7:32 amAh ok but how can I have setup something different from you? The code is the same
In general which are the possible codes that block or freeze an expression? -
Francesco Bona
August 22, 2018 at 8:28 amWAIT WAIT!!!! YOUR EXPRESSION WORKS!!! I WAS WRONG!
What made me think that it did not work is the “scale” of the second object.
It scale as its “anchor point” was still linked to the bottom margin of the first object.I’m understanding.. It’s my fault, I’m explaining very badly.
I need the second object to stop in that moment. But I also need, from that moment on, to be free to modify its property without being conditioned by the expression.The meaning is:
– Before frame 50 the second object remains linked to the bottom edge of the first object
– At frame 50 it stops with the exact dimension and position it has at that moment and if I do nothing it remains as it is and no longer follows the first object.
– After frame 50, If I change its parameters, such as position and scale, I must be free to do so without being bound by the expression that acted before. So from this moment I need it to behave as if it were created with these characteristics and position
Is this clearer? Sorry but as you can see my english depends on google and it’s really difficult for me to explain these things. -
Francesco Bona
August 22, 2018 at 9:34 amI add only one thing to clarify:
Perhaps my biggest mistake was to talk about “freezing” because this makes think of an object that from a certain moment on remains blocked as it is. I need it stops as it is not to be blocked forever with the properties it has in that moment.It is better to say that I’m looking a way to stop an expression to operate at a specific time, leaving the object as it is at that specific moment and free from its control.
The problem with last expression infact is that the object, from frame 50 on, seems to keep its properties forever linked to the conditionings it had in that frame. So what I get is not an object that I can control freely.
– position is locked as it was at frame 50
– scale anchor point is locked as it was at frame 50
So expression is not “off” as I need from frame 50 to on. Expreesion is frozen at frame 50.
I really need to find a way to make the expression stops to work after frame 50 but at the same time I need the object not simply to return as if it was without its control.I need the object to stops as it was at last frame the expression was active but without being conditioned by it from then on.
Reply to this Discussion! Login or Sign Up