• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Help with expression for position incremental stepping.

Community Beginner ,
Jun 12, 2020 Jun 12, 2020

Copy link to clipboard

Copied

Hello,

 

My project has a block of animated text that I would like to animate incramental postion. Evert ten frames, I want the position of the layer to move x amount on the Y axis. Much like the ticking of a clock, only linear. I have tried the following expression, and it works great for fluid motion, but as I have stated, I want stepping motion at a specific incriment. 

t = time;

s = 60;

v = t * s;

[value[0], value[1] + v]

I know it is something pretty simple, but I am having a tough time finding such a specific answer. Any help would be appreciated.

 

Thanks!

TOPICS
Expressions

Views

2.1K

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
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 12, 2020 Jun 12, 2020

If you want the property to jump in value every X number of frames all you have to do is divide the frame number of frames by the number of frames you want between moves, round the result, then multiply the property value you want to move by the change in value. Let's say that every 10 frames you wanted the Y position of a text layer to move up in y by 40 pixels. Let's start with the math, then build a value + array that lets you set the start position anywhere you want.

 

// set freqency and di
...

Votes

Translate

Translate
Community Beginner ,
Jun 12, 2020 Jun 12, 2020

Copy link to clipboard

Copied

There's probably a way to code that in an expression, but you can't use a global variable in AE, so you would need to write a very messy code just to reproduce this effect. You are better off using keyframes for this IMO.

Votes

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
community guidelines
Community Expert ,
Jun 12, 2020 Jun 12, 2020

Copy link to clipboard

Copied

If you want the property to jump in value every X number of frames all you have to do is divide the frame number of frames by the number of frames you want between moves, round the result, then multiply the property value you want to move by the change in value. Let's say that every 10 frames you wanted the Y position of a text layer to move up in y by 40 pixels. Let's start with the math, then build a value + array that lets you set the start position anywhere you want.

 

// set freqency and distance
countFrames = time/thisComp.frameDuration;
freq = countFrames / 10;
jump = Math.round(freq);
newY = jump * 40;
// Create Array
[value[0], value[1] - newY]]

 

This could also be used to set the jump time to decimal parts of a second instead of frames.

 

If the timing needed to be seconds, no matter what the frame rate is you would use Time instead of Time/Frame Duration.  Let's say you wanted to have a second hand that snaps from one number to the next every second. The math is really simple there too. A clock face has 60 seconds in 360º so each second the second hand must jump 6º. The expression would use the same math round operator but you would not need to create an array. It would look like this:

 

// Universal Second Hand
value + Math.round(time) * 6

 

 

Votes

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
community guidelines
Community Beginner ,
Jun 12, 2020 Jun 12, 2020

Copy link to clipboard

Copied

Thank you so much, Rick. I appreciate your reply, and the depth of your explaination. I read it twice, and it makes sense. I'll be applying this to my project as soon as I get back to work. 

 

Thanks again,

JE

Votes

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
community guidelines
Community Beginner ,
Jun 12, 2020 Jun 12, 2020

Copy link to clipboard

Copied

LATEST

I just used this expression and inserted the position offset that I calculated, and it works absolutely flawlessly. Thank you again.

Votes

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
community guidelines