Activity › Forums › Adobe After Effects Expressions › how to animate a value from a specific point in time?
-
how to animate a value from a specific point in time?
Posted by Assaf Goldlust on August 5, 2017 at 10:52 pmSo here is a challenge that im facing right now I can use some help.
Im trying to use an expression to make a value stay on zero until a certain point of time
And then make it start animating from zero to the end.The trick is: it should be something that can be easily modifiable.
So I can easily change the time were its supposed to start animating.Any suggestions?
Assaf Goldlust replied 8 years, 9 months ago 2 Members · 11 Replies -
11 Replies
-
Dan Ebberts
August 6, 2017 at 1:05 amIt’s hard to say exactly without knowing more about your animation, but in general, it will probably be something like this:
tStart = 3; // animation start time
if (time < tStart){
0;
}else{
// your animation here
}
Depending on what you’re doing, you may have to adjust your animation code to use (time-tStart) instead of time.
You could connect tStart to a slider to make it easier to adjust the start time.
Dan
-
Assaf Goldlust
August 6, 2017 at 8:48 pmPritty much what i did but still missing the part that may help me.
I will be more elobirate on this one.Im making an animation of slides that are moving from point of the frame to the other.
inside those each of those slides there is a footage.
i want this footage to stay on freeze frame and start playing only when the slide he is in has reached a specific position (i know i
originaly wanted to start moving when the CTI is has reached a certain time, but i made changes to the project)is there any way to pull this off?
-
Dan Ebberts
August 6, 2017 at 10:58 pmHere’s a simple example where a time remapped layer should start playing when it reaches 500 px in the x direction:
xPos = 500;
if (position[0] < xPos){
0;
}else{
t = time;
while (t >= 0){
if (position.valueAtTime(t)[0] < xPos){
break;
}
t -= thisComp.frameDuration;
}
if (t > 0)
time - t
else
0;
}
Dan
-
Assaf Goldlust
August 14, 2017 at 8:00 amI hope im not breaking any rule with a such delayed reply
but im having a problem.Since im trying to understand what makes the expressions i im using tick.
I tried to learn this “while/do statement” and while trying to test it i ran into an error i have never seen before,“Timeout while waiting for the engine Expression disabled”
Any idears about what does it mean
and how do i solve it?Also this is the expression i wrote while making the test
(R=transform.rotation;T=time;
while(T<3){R+1}
-
Dan Ebberts
August 14, 2017 at 1:18 pmOn any frame within the first three seconds of the comp, your expression will keep calculating the value of rotation plus one until the expression engine times out because the condition that would stop the while() never occurs.
Dan
-
Assaf Goldlust
August 14, 2017 at 7:31 pmSo lets see if i undrstood correctly:
the problem is that the exression dont have a defined comand about what to do when the condition to the loop is false? -
Dan Ebberts
August 14, 2017 at 7:47 pmNo, it’s that your while() will loop endlessly (until it times out) because the false condition never happens (for any frame within the first three seconds)
What is it that you want the expression to do? If you want the rotation to increment 1 degree every frame for three seconds, that would be something like this:
f = timeToFrames(Math.min(time,3));
value + fSince expressions have no memory and no info can be passed from one frame to the next, you have to calculate the result based on the current time/frame.
Dan
-
Assaf Goldlust
August 14, 2017 at 9:03 pm
What is it that you want the expression to do? If you want the rotation to increment 1 degree every frame for three seconds, that would be something like this:
yes and no…that what i was trying to do but only as a way to try to understand the “while do loop”
No, it's that your while() will loop endlessly (until it times out) because the false condition never happens (for any frame within the first three seconds)So let me see i got this right:
becuse expressions has no memory he keep calculating the loop on every frame and becuse the condition is never false untill three second its just loops endlessy on the each frame untill its times out?i dont get it: isent the whole purpose of “while do loop” is to get something to loop untill the condition becomes false?
dosent that makes the expression unsuable?
if it is how do i use it properly?
-
Dan Ebberts
August 14, 2017 at 9:26 pmHere’s an example of an incremental counter that holds each value a random amount of time (somewhere between 1 and 3 seconds):
seedRandom(index,true);
t = 0;
count = -1;
while(t <= time){
t += random(1,3);
count++;
}
count
Dan
-
Dan Ebberts
August 14, 2017 at 9:36 pmThe key is that since you can’t pass infomation from frame to frame, when dealing with random durations, you use the while() loop to recreate everything that has occured on past frames so you know what the current state should be.
Dan
Reply to this Discussion! Login or Sign Up