Highlighted

position frame duration expression

Community Beginner ,
Oct 06, 2020

Copy link to clipboard

Copied

Hi, I made 5 diffrent pictures and I want them to change when I change x position , I have no idea how to do it with expressions so please help 🙂 image.pngimage.png

Adobe Community Professional
Correct answer by Rick Gerard | Adobe Community Professional

When you use and expression to drive time remapping you have to write the expression so it delivers the time of the frame you want to see. The easiest way to convert a number into a frame is to divide it by the frame rate. An easy way to get the frame rate is to divide 1 by the comp's frame duration. 

 

The next step is to figure out how many pixels you want to move before you increase the frame count by 1.  You can either pick a number like 10 pixels or you can divide the comp width into the number of sections that you want to use. If you round the position change by the distance between frames and then divide that by the frame rate you will make time remapping jump to the next frame every time the layer moves the distance you have set between frames.

 

Up to this point, the expression would look like this:

fps = 1/thisComp.frameDuration;
distBtwnFrames = thisComp.width / 10;
posChange = position[0];
fr = Math.floor(posChange / distBtwnFrames)/fps;

You've got to fix your pre-comp so that it doesn't have a blank frame - it needs 4 layers, not 3, or you have to set the pre-comp to 3 frames and eliminate the empty frame. 

 

Move the layer to the left side of the comp and you will see frame 1, then it will switch to frame 2, then 3, 4, the frames will be used up and the screen will go blank. 

 

You'll need to set up a loop to keep repeating the first frames as the layer moves from left to right. It's been a long day and I'm not sure how to write that loop without opening up AE and fiddling for a while. Maybe somebody else will step in and finish the expression for you, but this much should make your animated graphic take 4 steps (3 steps if you don't have another drawing) as you move the layer from the left side of the screen to the right until you run out of frames. 

 

Somebody like Dan Ebberts could write the looping part of the expression in about 2 seconds, and maybe even clean up the rest of it a bit, but this will get you started. 

TOPICS
Error or problem, Expressions, How to

Views

109

Likes

Translate

Translate

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 frame duration expression

Community Beginner ,
Oct 06, 2020

Copy link to clipboard

Copied

Hi, I made 5 diffrent pictures and I want them to change when I change x position , I have no idea how to do it with expressions so please help 🙂 image.pngimage.png

Adobe Community Professional
Correct answer by Rick Gerard | Adobe Community Professional

When you use and expression to drive time remapping you have to write the expression so it delivers the time of the frame you want to see. The easiest way to convert a number into a frame is to divide it by the frame rate. An easy way to get the frame rate is to divide 1 by the comp's frame duration. 

 

The next step is to figure out how many pixels you want to move before you increase the frame count by 1.  You can either pick a number like 10 pixels or you can divide the comp width into the number of sections that you want to use. If you round the position change by the distance between frames and then divide that by the frame rate you will make time remapping jump to the next frame every time the layer moves the distance you have set between frames.

 

Up to this point, the expression would look like this:

fps = 1/thisComp.frameDuration;
distBtwnFrames = thisComp.width / 10;
posChange = position[0];
fr = Math.floor(posChange / distBtwnFrames)/fps;

You've got to fix your pre-comp so that it doesn't have a blank frame - it needs 4 layers, not 3, or you have to set the pre-comp to 3 frames and eliminate the empty frame. 

 

Move the layer to the left side of the comp and you will see frame 1, then it will switch to frame 2, then 3, 4, the frames will be used up and the screen will go blank. 

 

You'll need to set up a loop to keep repeating the first frames as the layer moves from left to right. It's been a long day and I'm not sure how to write that loop without opening up AE and fiddling for a while. Maybe somebody else will step in and finish the expression for you, but this much should make your animated graphic take 4 steps (3 steps if you don't have another drawing) as you move the layer from the left side of the screen to the right until you run out of frames. 

 

Somebody like Dan Ebberts could write the looping part of the expression in about 2 seconds, and maybe even clean up the rest of it a bit, but this will get you started. 

TOPICS
Error or problem, Expressions, How to

Views

110

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

look for info on "time remapping"

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

yeah , Im looking for an expression that links time remapping with position and couldn't find anything !

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 06, 2020 0
Community Beginner ,
Oct 06, 2020

Copy link to clipboard

Copied

ok try to work around these :

on your precomp layer position  : paste :

 

 

xy= value; //pair of coordinates

x= xy[0];
y= xy[1];

[x+timeToFrames(timeRemap*200),y]

 

to go the other side, from position to timeremap, try this on timeremap of another precomp layer :

transform.position[0]/1000

 

these won't do exactly what you want, see them as starters, to get you started

🙂

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 06, 2020 1
Adobe Community Professional ,
Oct 06, 2020

Copy link to clipboard

Copied

When you use and expression to drive time remapping you have to write the expression so it delivers the time of the frame you want to see. The easiest way to convert a number into a frame is to divide it by the frame rate. An easy way to get the frame rate is to divide 1 by the comp's frame duration. 

 

The next step is to figure out how many pixels you want to move before you increase the frame count by 1.  You can either pick a number like 10 pixels or you can divide the comp width into the number of sections that you want to use. If you round the position change by the distance between frames and then divide that by the frame rate you will make time remapping jump to the next frame every time the layer moves the distance you have set between frames.

 

Up to this point, the expression would look like this:

fps = 1/thisComp.frameDuration;
distBtwnFrames = thisComp.width / 10;
posChange = position[0];
fr = Math.floor(posChange / distBtwnFrames)/fps;

You've got to fix your pre-comp so that it doesn't have a blank frame - it needs 4 layers, not 3, or you have to set the pre-comp to 3 frames and eliminate the empty frame. 

 

Move the layer to the left side of the comp and you will see frame 1, then it will switch to frame 2, then 3, 4, the frames will be used up and the screen will go blank. 

 

You'll need to set up a loop to keep repeating the first frames as the layer moves from left to right. It's been a long day and I'm not sure how to write that loop without opening up AE and fiddling for a while. Maybe somebody else will step in and finish the expression for you, but this much should make your animated graphic take 4 steps (3 steps if you don't have another drawing) as you move the layer from the left side of the screen to the right until you run out of frames. 

 

Somebody like Dan Ebberts could write the looping part of the expression in about 2 seconds, and maybe even clean up the rest of it a bit, but this will get you started. 

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Thank you so much 

Likes

Translate

Translate

Report

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