ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Change position of Marker on timeline

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Mackie john
Change position of Marker on timeline
on Jan 4, 2019 at 12:55:05 pm

Is 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.


Return to posts index

Dan Ebberts
Re: Change position of Marker on timeline
on Jan 4, 2019 at 2:04:37 pm

You can't move a marker with an expression.

Dan



Return to posts index

Mackie john
Re: Change position of Marker on timeline
on Jan 4, 2019 at 4:27:43 pm

THanks 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)
}


Return to posts index


Dan Ebberts
Re: Change position of Marker on timeline
on Jan 4, 2019 at 4:57:03 pm

It'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



Return to posts index

Mackie john
Re: Change position of Marker on timeline
on Jan 4, 2019 at 5:06:41 pm

Yes, 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)}



Return to posts index

Dan Ebberts
Re: Change position of Marker on timeline
on Jan 4, 2019 at 5:17:44 pm

No, 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



Return to posts index


Mackie john
Re: Change position of Marker on timeline
on Jan 4, 2019 at 5:35:01 pm

Yes 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.


Return to posts index

Dan Ebberts
Re: Change position of Marker on timeline
on Jan 4, 2019 at 5:37:31 pm

What does your calculation for clockTime look like?


Dan



Return to posts index

Mackie john
Re: Change position of Marker on timeline
on Jan 4, 2019 at 5:42:18 pm

I 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);


Return to posts index


Dan Ebberts
Re: Change position of Marker on timeline
on Jan 4, 2019 at 5:55:14 pm

You 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



Return to posts index

Mackie john
Re: Change position of Marker on timeline
on Jan 4, 2019 at 6:00:46 pm

Perfect, 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.


Return to posts index

Mackie john
Re: Change position of Marker on timeline
on Jan 4, 2019 at 6:11:20 pm

Just another thing, If I have multiple key frames on the same property. How will I target the 2nd key frame. E.g. I have 1 for fade in, another for fade out. How do I target for fade out ?


Return to posts index


Dan Ebberts
Re: Change position of Marker on timeline
on Jan 4, 2019 at 6:50:50 pm

I'm guessing that would look like this:

valueAtTime(actionTime + key(2).time)


Dan



Return to posts index

Mackie john
Re: Change position of Marker on timeline
on Jan 4, 2019 at 7:00:31 pm

Yes great it works fine. Thanks once again.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]