Activity › Forums › Adobe After Effects Expressions › start/stop expression at specific time
-
start/stop expression at specific time
Posted by Atomicrabbit on July 27, 2007 at 7:12 pmIs there a way to start/stop an expression at a specific time. I’ve tried using a checkbox with if statement to start it at a specific frame and it worked fine, but when I turn it off to stop the expression, it does not stay at the position the expression moved it to. It reverts to the size/position it was before the expression.
How can I get around this problem.
James Valpy replied 6 years ago 13 Members · 43 Replies -
43 Replies
-
Mike Clasby
July 27, 2007 at 7:25 pmok, somebody will have a more sophisticated solution, but to keep that expression value (Position) you can always split the layer (Edit>Split Layer) then on that upper layer set a Position keyframe (or whatever property the expression is on), then disable the expression (click the equal sign next to the stopwatch). You should be good to go.
-
Atomicrabbit
July 27, 2007 at 8:08 pm[Dan Ebberts] “What’s the code for your expression?
Dan”
I found this code from a post. It’s to make a falling leaf effect, but I modified the code a little. I’m also using a checkbox to start the expression.
position
———————————————————————————–
control = effect(“Checkbox Control”)(“Checkbox”) ;
whattime=time-3;
if (control == 1){
sp=2;
amp=150;
gravity = 50;
x = Math.sin(whattime*sp)*amp;
y = Math.sin(whattime*1.5)*50;
value + [x,y];
}else{
value;
}scale
————
control = effect(“Checkbox Control”)(“Checkbox”) ;
whattime=time-3;
if (control == 1 || value > 40){
gravity = 50;
z= whattime*whattime
value – [z,z];
}else{
value;
}rotation
————————————————————————————
control = effect(“Checkbox Control”)(“Checkbox”) ;
whattime=time-3;
if (control == 1){
sp=2;
amp=5;
x = Math.sin(whattime*sp)*amp;
value – x;
}else{
value;
} -
Dan Ebberts
July 27, 2007 at 8:38 pmGive this a try (for position):
chkBx = effect(“Checkbox Control”)(“Checkbox”);
n = 0;
if (chkBx.numKeys > 0){
n = chkBx.nearestKey(time).index;
if (chkBx.key(n).time > time){
n–;
}
}t = 0;
curTime = time;if (n > 0){
for (i = n; i > 0; i–){
if (chkBx.key(i).value > 0){
t += (curTime – chkBx.key(i).time);
}
curTime = chkBx.key(i).time;
}
if ((curTime > 0) && (chkBx.key(1).value > 0)) t += curTime;
}else{
if (chkBx.value > 0) t = time;
}sp=2;
amp=150;
gravity = 50;
x = Math.sin(t*sp)*amp;
y = Math.sin(t*1.5)*50;
value + [x,y];Dan
-
George Costakis
April 4, 2009 at 11:43 pmI doubt anyone will see this, but what about for this expression?
veloc = 7;
amplitude = 80;
decay = .7;amplitude*Math.sin(veloc*time)/Math.exp(decay*time)
right now it starts at the beginning of the comp even if i try the split and duplicate layer trick. any help would be great.
-george -
Brennan Shappell
August 25, 2010 at 4:25 pmI also am trying to get the decaying pendulum expression to start at a time specified(not the beginning of the comp).
Thanks for any help!veloc = 5;
amplitude = 20;
decay = .9;amplitude*Math.sin(veloc*time)/Math.exp(decay*time)
-
Dan Ebberts
August 25, 2010 at 5:31 pmThis is one way:
beginTime = 4; // start at 4 seconds
if (time < beginTime){
0
}else{
t = time - beginTime;
veloc = 5;
amplitude = 20;
decay = .9;
amplitude*Math.sin(veloc*t)/Math.exp(decay*t)
}
Dan
-
Brennan Shappell
August 25, 2010 at 5:36 pmThanks for the absurdly fast turn around time on that, Dan =]
Works like a charm. -
Duca Simone luchini
October 27, 2011 at 7:56 pmHallo Dan, I didn’t understand in this your code where is the END parameter where the expression stops. I Understood that at 4 second starts expression (beginTime = 4;)
BUT where stops???
For instance, in your expression (), if the comp is 10 seconds and I’d like to activate expression from 2 second to 8 second, what I have to write?beginTime = 4; // start at 4 seconds
if (time < beginTime){ 0 }
else{ t = time – beginTime;
veloc = 5; amplitude = 20; decay = .9; amplitude*Math.sin(veloc*t)/Math.exp(decay*t) }THX!
-
Dan Ebberts
October 27, 2011 at 8:21 pmIt doesn’t actually stop. Eventually it settles out to approximately zero, but the timing depends on the decay variable. If you wanted it to just stop at whatever value corresponds to 8 seconds, you could do this:
beginTime = 4; // start at 4 seconds
endTime = 8;
if (time < beginTime){
0
}else{
t = Math.min(time,endTime) - beginTime;
veloc = 5;
amplitude = 20;
decay = .9;
amplitude*Math.sin(veloc*t)/Math.exp(decay*t)
}
Dan
Reply to this Discussion! Login or Sign Up