Highlighted

## Position expression help

Community Beginner ,
Apr 12, 2020

Copied

Hello,

I'm looking for an expression that makes object moves horizontally from beginning of comp to end bassed on layer inPoint and outpoint

And let me control speed of moving

Thanks.

TOPICS
Expressions

Views

207

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

## Position expression help

Community Beginner ,
Apr 12, 2020

Copied

Hello,

I'm looking for an expression that makes object moves horizontally from beginning of comp to end bassed on layer inPoint and outpoint

And let me control speed of moving

Thanks.

TOPICS
Expressions

Views

208

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 12, 2020 0
5 Replies 5
Explorer ,
Apr 12, 2020

Copied

``````dur = 10;

x = linear(time, inPoint, inPoint+dur,0,thisComp.widh);

[x,value[1]]
``````

dur is the duration of the animation. So the bigger dur is, the slower the layer moves.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 12, 2020 0
Apr 13, 2020

Copied

If you mean that you want to have a layer move from one side of the composition to the other side then the speed of that move depends entirely on the time between the in and out point.

If you want to control the speed then you can't care about the out point and you have already been given a solution.

Fix the typo (widh to width) in the expression andreip14565073  posted and you have an expression that will move a layer 0, in X to the other side of the comp in 10 seconds. Tie an expression control slider to "dur =" and you might have something you can use.

To have the motion controlled by the in and out points you need this:

``````t = time - inPoint;
et = outPoint - inPoint;
x = ease(t, 0, et, 0, width);
[x, value[1]]``````

To make it even more useful you could calculate the layer width and factor in the scale so that the layer would slide it from the left side and then exit on the right side all based on the layers in and out points.

I have about a hundred of these that do all kinds of animation just based on the layers in and out points. I'll share one with you that will take any layer of any size or scale and fly it in from the left to any position you want, bounces to a stop, and then just before the layer ends it falls off the bottom of the screen. You'll see the code to tie size and scale in the animation preset.

https://www.dropbox.com/s/tewk9s88mpkmnou/flyInBounceDropOut.ffx?dl=0

Hope this helps.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 13, 2020 1
Community Beginner ,
Apr 13, 2020

Copied

Its works good, but there is one thing else

The layer not starts from out of the comp

Half of it shown at start, can i make hole layer out in inPoint or may i change  anchor point ?

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 13, 2020 0
Apr 13, 2020

Copied

If you want the layer to start outside of the frame so that it is not visible and end outside of the frame you need to add those dimensions to the position property. Did you look at the animation preset that I posted? The language to do that is included. It needs to be modified. The X value of the anchor point needs to be at the center of the layer.

Here's the modified expression:

``````// Fix  layer size when scaled
sf = scale - [100, 100];
xSize = width + (width * sf[0]/100);
ySize = height + (height * sf[1]/100);
realSize = [xSize, ySize];
// Set Positions
spx = 0 - realSize[0] + realSize[0]/2 ;
rstx = value [0];
rsty = value[1];
epx = thisComp.width + realSize[0] - realSize[0]/2;
// create movement
t = time - inPoint;
et = outPoint - inPoint;
x = ease(t, 0, et, spx, epx);
[x, value[1]]``````

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 13, 2020 1
LATEST
Community Beginner ,
Apr 19, 2020

Copied

1. Thanks alot