Activity › Forums › Adobe After Effects Expressions › Change position of Marker on timeline
-
Change position of Marker on timeline
Posted by Mackie John on January 4, 2019 at 12:55 pmIs it possible to move a Layer marker position to a new position. I have this marker connected to an animation. And want to control the position of the marker using expression so I can control or delay the animation.
Mackie John replied 7 years, 4 months ago 2 Members · 13 Replies -
13 Replies
-
Mackie John
January 4, 2019 at 4:27 pmTHanks for informing DAN.
Below is a script that I took from one of your answers online, I want modify this when the counter goes 0, the keyframe should play. is it possible. Can you show how to achieve this
var clockTime // this is my counter value, script not shown here for simplicity.
// So when this var goes 0, I need the valueAtTime to play.L= thisComp.layer("EDIT");
n = 0;
if (L.marker.numKeys > 0){
n = L.marker.nearestKey(time).index;
if (L.marker.key(n).time > time){
n--;
}}if (n == 0){
valueAtTime(0);
}else{
t = time - L.marker.key(n).time;
valueAtTime(t)
} -
Dan Ebberts
January 4, 2019 at 4:57 pmIt’s tricky. When you want something to trigger an animation, the expression generally has to figure out how long ago the trigger happened, and that usually requires some knowledge of how the trigger works. For example, does the clock stop at zero? If so, your expression can check if the clock is zero now, and if so, go back in time, frame by frame, to find the frame where it first went to zero. That will tell you how long it’s been zero and therefore, how far along into the triggered animation you should be. If the counter keeps going, maybe the expression can tell from the current value how long ago it reached zero. If the counter can reach zero multiple times, the algorithm will be different.
Dan
-
Mackie John
January 4, 2019 at 5:06 pmYes, the counter turns zero, after which I want to run the animation (keyframes):
Here, I have thought of two ways. Can you suggest if this is correct or can be improved. FIrst is using valueAtTime, second is using linear:
if (clockTime == 0){
chkTime = time - clockTime;
valueAtTime(chkTime)
}if (clockTime == 0){
chkTime = time - clockTime;
linear(chkTime , 0, 6, 100, 0)} -
Dan Ebberts
January 4, 2019 at 5:17 pmNo, those won’t work. You need to know how long clockTime has been zero. If you’re calculating clockTime in the same expression, you can probably just modify that calculation to include calculating how long it has been zero.
Dan
-
Mackie John
January 4, 2019 at 5:35 pmYes I understand what you mean, but i’m not getting it. I’m a little weak in expressions and learning them as I go.
I know what I want to achieve but the part I’m missing is how can I calculate how long it has been 0. Can you help with an example, if possible. Will be grateful.
-
Mackie John
January 4, 2019 at 5:42 pmI will be feeding clockStart which is just a text layer now externally (outside of aftereffects). So it will come in as in `int`. Right now I have put it a text layer for testing only.
clockStart = parseInt(thisComp.layer(1).text.sourceText.value);
clockTime = Math.max((clockStart-1*(time-inPoint)),0); -
Dan Ebberts
January 4, 2019 at 5:55 pmYou could first calculate what clockTime would be if you let it go negative (rawClockTime) and then use that to calculate how far into the animation you should be (actionTime). Something like this:
clockStart = parseInt(thisComp.layer(1).text.sourceText.value);
rawClockTime = clockStart-1*(time-inPoint);
clockTime = Math.max(rawClockTime,0);
actionTime = (rawClockTime < 0) ? -rawClockTime : 0;
Then use actionTime to drive your animation (using ValueAtTime()).
Dan
-
Mackie John
January 4, 2019 at 6:00 pmPerfect, I’m grateful to you. It’s working as I wanted, I have understood the logic as well. Thank you so much for you help.
Reply to this Discussion! Login or Sign Up