ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Move layer from exact position A to B and hold time X

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Michael Kampe
Move layer from exact position A to B and hold time X
on Aug 14, 2019 at 5:08:50 pm

Hi dear expressionists,

I´m starting to get into expressions and I can´t figure out how to do it.
Most threads here are so advanced in terms of their needs, that I simply don´t understand them or could easily c/p parts of it to my needs.

Question:
I have a shape layer on an exact position A (2D). It should stay there (let´s say 10sec.) and then move (not linear, with a little bezier curve) to and exact position B (also 2D). Then it should stay there (let´s say also10sec.) and then move back to the exact position A. How can I do it?

Question add on:
If this looks all to "static" and predictable (10sec this.... 10sec that etc.), how can I add a randomness to the "hold time" value? Let´s say that it holds the time between 5-20sec.)?

Hope it is not too dumb from my side (to ask) and too complicated on your side (to help me) and you can assist me. 😊
Thanks a lot in advance.

Best
Michael


Return to posts index

Dan Ebberts
Re: Move layer from exact position A to B and hold time X
on Aug 14, 2019 at 9:59:41 pm

Simple example:


holdDur = 10;
moveDur = 1;
positionB = [100,100];

t1 = holdDur;
t2 = t1+moveDur;
t3 = t2+holdDur
t4 = t3+moveDur;

if (time < t1){
value
}else if (time < t2){
ease(time,t1,t2,value,positionB)
}else if (time < t3){
positionB
}else if (time < t4){
ease(time,t3,t4,positionB,value)
}else{
value
}



Dan



Return to posts index

Michael Kampe
Re: Move layer from exact position A to B and hold time X
on Aug 15, 2019 at 9:47:53 am

Hi Dan,

thank you soooooo much for your help. 😍It worked....

ok, kind of.

The "movement" in your expression starts at 10sec. The shape moves to position B, stays there for 10sec. and then moves back. So far so good.

But after that, it doesn't move anymore. My comp is ca. 2:30min long. How can I do it, that the shape layer "uses" the expression all the way through the end?

And when I wanted to be brave and tried to give the "waiting time" some randomness... (eg. holdDur = random(5,20); it all gets messy.
Kind of a flickering movement starting at 5sec. until 40sec. and then again no movement at all anymore. Do you know why and can help me?

Thank you very much in advance.
best
Michael


Return to posts index


Dan Ebberts
Re: Move layer from exact position A to B and hold time X
on Aug 15, 2019 at 1:51:38 pm

To get it to repeat and add some randomness to the hold duration would be more like this:


seedRandom(index,true);
holdDur = random(5,20);
moveDur = 1;
positionB = [100,100];

t1 = holdDur;
t2 = t1+moveDur;
t3 = t2+holdDur
t4 = t3+moveDur;

t = time % t4;

if (t < t1){
value
}else if (t < t2){
ease(t,t1,t2,value,positionB)
}else if (t < t3){
positionB
}else{
ease(t,t3,t4,positionB,value)
}


If you want each iteration to have a different random hold value, that's a different situation entirely...

Dan



Return to posts index

Michael Kampe
Re: Move layer from exact position A to B and hold time X
on Aug 15, 2019 at 3:05:31 pm

Hi Dan,

thank you very much for your help. Worked fantastic in terms of the whole timeline. 😍

What is the difference between
To get it to repeat and add some randomness to the hold duration would be more like this:

and
If you want each iteration to have a different random hold value, that's a different situation entirely...
?
Right now, I have the feeling it holds always ca. 10sec. If I want the "hold" between ,lets say, 5sec. and 20sek. .....is that the different story you're talking about? Because holdDur = random(5,20); didn't have an impact now (so it seems to me).

Thanks again for your help.
best
Michael



Return to posts index

Dan Ebberts
Re: Move layer from exact position A to B and hold time X
on Aug 15, 2019 at 5:53:09 pm

The way it is now, each layer will have a different hold time between 5 and 20 sec. but that hold time will apply for the duration of the comp. Having the same layer have a different hold time for each iteration is the different story.


Dan



Return to posts index


Michael Kampe
Re: Move layer from exact position A to B and hold time X
on Aug 15, 2019 at 6:40:15 pm

Hi Dan,

Thx for your help. Does this means, I have to put this expression on every shape layers position (with the change of position b of course), so that each layer uses a different hold time?

Best
Michael



Return to posts index

Dan Ebberts
Re: Move layer from exact position A to B and hold time X
on Aug 15, 2019 at 6:42:56 pm

That's correct.


Dan



Return to posts index

Michael Kampe
Re: Move layer from exact position A to B and hold time X
on Aug 15, 2019 at 7:04:24 pm

Hi Dan,

Sounds great. Thx again. Right now, each layer moves from point a to b in a „straight“ line. If I want to have a slightly cruved movement, this is very tricky and complicated and also a different story?

Best
Michael



Return to posts index


Dan Ebberts
Re: Move layer from exact position A to B and hold time X
on Aug 15, 2019 at 9:03:58 pm

I can think of a few ways to do that (depending on the type of curve you're after), but they all complicate things somewhat.


Dan



Return to posts index

Michael Kampe
Re: Move layer from exact position A to B and hold time X
on Aug 15, 2019 at 10:08:45 pm

Hi Dan,

Thx for the head up. Just thinking out loud... would it be much easier, if I curvy animate via keyframes the movement between position a to b and back to position a AND use a random pause expression until the animation starts all over? Is that possible?

Best
Michael



Return to posts index

Dan Ebberts
Re: Move layer from exact position A to B and hold time X
on Aug 15, 2019 at 11:29:09 pm

If you define your curved motion with 3 keyframes (A position, B positon, A position), something like this should work:

seedRandom(index,true);
holdDur = random(5,20);
moveDur1 = key(2).time - key(1).time;
moveDur2 = key(3).time - key(2).time;


t1 = holdDur;
t2 = t1+moveDur1;
t3 = t2+holdDur
t4 = t3+moveDur2;

t = time % t4;

if (t < t1){
tCur = key(1).time
}else if (t < t2){
tCur = linear(t,t1,t2,key(1).time,key(2).time)
}else if (t < t3){
tCur = key(2).time
}else{
tCur = linear(t,t3,t4,key(2).time,key(3).time)
}
valueAtTime(tCur)




Dan



Return to posts index


Michael Kampe
Re: Move layer from exact position A to B and hold time X
on Aug 19, 2019 at 3:25:12 pm

Hi Dan,


you are the best. Thank you so much... that's exactly what I need. 😍

I made a mistake 😫 in terms of keyframes. I need at least 4 and not 3. 6 would be even better.
The point is, I need an "in-between" keyframe, that hold the layer in position until it start to go back to position A. Right now (with only 3 keyframes) it moves from position A to B (as expected) and then straight back to point B. I need a "resting" moment for position B.

I tried to look into your script, but to insert an additional key(4) is above my knowledge.

Thank you again for your help
best
Michael



Return to posts index

Dan Ebberts
Re: Move layer from exact position A to B and hold time X
on Aug 19, 2019 at 5:05:07 pm

For 4 keyframes, I think you just need to change this line:

tCur = linear(t,t3,t4,key(2).time,key(3).time)

to this:

tCur = linear(t,t3,t4,key(3).time,key(4).time)


Dan



Return to posts index

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