ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# position Y loop issue

FAQ   •   VIEW ALL
 position Y loop issue on May 25, 2017 at 11:05:01 am

Hello,

I am new to this forum. Nice to e-meet you.

I had look for this answer and I can't find a solution.

I have this code:

I have a shape layer. I want this layer to scroll from the top to the bottom and reset its position to top again when is out of the screen.

I have this code and it doesn't work. Can you help me? Thank you!

```X=position[0]; Y=position[1]; if (Y <= thisComp.height) { [X,Y*time]; } else { [X,Y - 200]; }```

 Re: position Y loop issueon May 26, 2017 at 12:03:26 pm

Hi,

I think this works (t is the Y animation duration in seconds):

X=position[0];
Y=position[1];
a = thisComp.height;
t = 4;

[X,linear(t, -a/2, (1.5*a*time/t)-((a/(2*t))*(t-time)))];

if(time>=t){
[X, -a/2]
};

Here's what I think is going on :
I first wanted to put a linear interpolation and then check the time to send it back to it's original position.
Since the final value is in an if statement, it recalculates the value every frame, so a simple linear doesn't work.
I then noticed that it was tacking the last value of the linear interpolation in account.
So I modified that final destination value to "fit" the animation...

Hope this helps !
;)

 Re: position Y loop issueon May 27, 2017 at 6:56:45 am

Thank you!

I am trying to do a delay using index as multiplier. But no success.

 Re: position Y loop issueon May 27, 2017 at 8:38:55 am

Hi again,

What you can do, is make a master layer with the expression on it, hide it if you want.
Then, you put this expression on the other layers position property :

a = 3;
thisComp.layer("Main").transform.position.valueAtTime(time-thisLayer.index * a);

by changing "a", you change the delay ðŸ˜‰

Hope this helps,

Cheers !