ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Move, hold, move based on layer duration

FAQ   •   VIEW ALL
 Move, hold, move based on layer duration on Jan 8, 2018 at 11:57:05 pm

I have a script that fades in and fades out based on my layer's duration (huge time saver).

Now I'm wondering if I can have my layer (text) start at one position, move to a second position, hold on that position, and then move to a third position.

Ideally, each change in position would occur over a quarter of a second, and the hold would be anything in between.

I have a huge animation with text and AI layers and I'm trying to bring consistency without having to deal with the insane amount of keyframes I already have.

 Re: Move, hold, move based on layer durationon Jan 9, 2018 at 9:16:24 am

There is probably better ways to do this.

a is when you want the animation to happen, I've included inPoint of the layer, so that if you move the layer, it'll re adjust itself.
t is the time the animation will last.
posa is the first position
posb is the second position it will hold on
posc is the final position

a = 4;
t =.5;

posa = [0,0];
posb = [100,100];
posc = [100,1000];

if((time > inPoint) && (time < inPoint + a)){
ease(time,inPoint,inPoint+t,posa,posb)
}else{
ease(time,inPoint + a,inPoint + a + t,posb,posc)
}

Like I said, there is probably an easier method, but this is how I would do it currently at my level of expertise.

Hope this is of use

 Re: Move, hold, move based on layer durationon Jan 9, 2018 at 6:19:04 pm

You definitely pushed me in the right direction. I was able to simplify it a bit. I didn't need the "a" variable, because I want to base it on the length of the layer. I also noticed that the first frame of the layer was being caught by the "else" portion of the script, so I changed it to be at or less than the inPoint + the duration of the animation.

Then as I wanted the else statement to occur at whatever the end of the layer was, I used the outPoint variable minus the animation time.

Works great, thank you so much!

```t =.25; posa = [0,0]; posb = [100,100]; posc = [100,200]; if(time &lt;= inPoint + t) { ease(time,inPoint,inPoint + t,posa,posb) }else{ ease(time,outPoint - t,outPoint,posb,posc) }```

 Re: Move, hold, move based on layer durationon Jan 10, 2018 at 8:21:49 am

You can tell I don't read posts thoroughly.

If you got that to work brill.

An alternative, as well is (time < (inPoint + outPoint)/2) which simply means, if I'm before the middle of the layer. I use this a lot, for scaling and position, but I've never had to go to a third point.

t =.25;

posa = [0,0];
posb = [100,100];
posc = [100,200];

if(time < (inPoint + outPoint)/2) {
ease(time,inPoint,inPoint + t,posa,posb)
}else{
ease(time,outPoint - t,outPoint,posb,posc)
}

it makes no difference really i think... With me still getting used to expressions 2 years later < or >...they break my brain haha, as I don't know if they have a significant difference to writing it < or >.