Activity › Forums › Adobe After Effects Expressions › start/stop expression at specific time
-
Duca Simone luchini
October 28, 2011 at 7:05 amThx Dan,
my problems with expression is almost alway the same Start and End it at a determinate time…
Regardless of the content of the expression, I would like to understand what commands to use to start a particular second and make it cease to another second…
For example, i have this expression applied ti Light parameter:probability = 6;
opacity_normal = 100;
x = random(probability);
if (x <= 1) {
opacity = random(100);
} else {
opacity = opacity_normal;
}I’d like to apply to this expression a Start time (at 36th second) and a n End time (at 39th second). Can I utilize your command? Something like this…:
beginTime = 36;
endTime = 39;
probability = 6;
opacity_normal = 100;
x = random(probability);
if (x <= 1) {
opacity = random(100);
} else {
opacity = opacity_normal;
}?????
THX!
-
Dan Ebberts
October 28, 2011 at 7:36 amIt would be more like this:
beginTime = 36;
endTime = 39;
probability = 6;
opacity_normal = 100;
if (time >= beginTime && time < endTime){
x = random(probability);
if (x <= 1) {
random(100);
} else {
opacity_normal;
}
}else{
opacity_normal;
}
Dan
-
Sefik Soyer
January 19, 2012 at 2:42 pmHi Dan,
It’s my first time posting here on this forum, kind of excited and hope I can make it work 🙂
Apparently this subject (Start/Stop Expression at Specific Time) has been out here for a long time, and even though I think I thoroughly looked into it, somehow I couldn’t make the code work for me 🙁
Basically, I wanted my expression to start at a certain frame but as I just mentioned I couldn’t figure out what I’m doing wrong after I spent 3 hours and gave up at this point!
I have a composition with 12fps and I have my TEXT layer, which I applied the expression on ‘the expressions code box’ below to its POSITION parameter, hoping that it would move on x-axis, however it doesn’t do anything at all!
But when I just use this code below:
freq = 15;
amplitude = 100;
decay = 3;x = amplitude*Math.cos(freq*time*2*Math.PI)/Math.exp(decay*time);
position + [x,0];Then it works but it starts moving at the beginning of my composition, not on the frame I want it to.
I tried everything that has been mentioned on this thread ( interestingly some scripts don’t even work at all for me) and I did search on Adobe’s forum as well, which I’ll post there as well in a second 🙂
So what am I doing wrong ?
How am I going to make my expression work and move the TEXT layer as it is supposed to on that specific frame I would like to ?
Any kind of answer/help/explanation will be greatly appreciated 🙂
Have a great day!
cheers,
Sefik
beginTime = 40;
if (time > beginTime) {freq = 15;
amplitude = 100;
decay = 3;x = amplitude*Math.cos(freq*time*2*Math.PI)/Math.exp(decay*time);
position + [x,0];} else {
0
} -
Dan Ebberts
January 19, 2012 at 3:19 pmAssuming you want it to start at frame 40, try it this way:
beginFrame = 40;t = time - framesToTime(beginFrame);
if (t >= 0) {
freq = 15;
amplitude = 100;
decay = 3;
x = amplitude*Math.cos(freq*t*2*Math.PI)/Math.exp(decay*t);
value + [x,0];
}else
value
Dan
-
Sefik Soyer
January 19, 2012 at 3:28 pmDan,
You’re the man as we already all know!
Thanks a lot 🙂
Now I can go to sleep finally and peacefully :))
-
Ziggy Ziegelmueller
March 6, 2014 at 1:01 amSO, I am a bit of a noob at after effects, but I am having the same problem: not being able to start/stop expressions at the desired time. After finding this thread, I figured i would give it an ask. I will use the common “wiggle” expression as an expression template. Thi sis waht I have tagged to Position on a null object that is parented to a camera:
beginTime = 4; // start at 4 seconds
endTime = 8;
if (time < beginTime
It returns this error (I have tried with the N.O. as a 3d layer as well as a 2d one)."expression result must be of dimension 2, not 1"
Any ideas? -
Dan Ebberts
March 6, 2014 at 1:10 amI’d say try it this way:
beginTime = 4; // start at 4 seconds
endTime = 8;
if (time > beginTime && time < endTime)
wiggle(2,10)
else
value
Dan
-
Cameron Walser
April 16, 2014 at 8:05 pmHi – I hope this hasn’t been answered above. Very helpful thread!
So I’m trying to have a simple translation expression evaluate between a start and stop time, but when it ends, I want the object to retain it’s translation it ended up with at the end of the expression’s evaluation. As it currently is, the object jumps back to it’s original position, which is no surprise….!
Any help would be greatly appreciated!
beginTime = 1;
endTime = 30;x = transform.position[0]
yOrigin = 520;
yDelta = -10;if (beginTime <= timeToFrames(time) && timeToFrames(time) <= endTime ) {
newY = yOrigin + timeToFrames() * yDelta; }
else newY = yOrigin;[ x, newY]
-
Cameron Walser
April 16, 2014 at 8:28 pmOh shoot – I should add this new problem in too.
I want to add a random value to the position’s translation, but the expression recalculates the random value that it adds every time. See below.
Basically I want to create an expression that translates a layer a random amount between a specified start and stop time (which ideally will depend on the layer’s own start and stop time, so I can randomize that as well) – Then I can duplicate the hell out of that layer, and slide the layers in time, and have a whole bunch of layers translating different amounts…
PS the garbled characters should be <
something odd going on here in ASCII landbeginTime = inPoint;
endTime = outPoint;x = transform.position[0]
yOrigin = 520;
yDelta = random (-10,10);if (beginTime < = time && time < = endTime ) {
newY = yOrigin + timeToFrames() * yDelta; }
else newY = yOrigin;[ x, newY]
Reply to this Discussion! Login or Sign Up