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

Adobe After Effects Expression

Community Beginner ,
Jul 02, 2023 Jul 02, 2023

var x = 0;

 

var y = 2;

 

var z = 10;

 

I want var x value to be increased by 1 (x + 1) after every var y seconds untill time is equal to var z.

 

What to do?

TOPICS
Expressions , Scripting
587
Translate
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 , Jul 02, 2023 Jul 02, 2023

Dan's idea to use floor to increase by 1 is very elegant. But I think your condition with the z must be implemented like this (since z should be a limit on the time, not on the final value, if I understand it correctly):

x = Math.floor(Math.min(time,z)/y);

Translate
Community Expert ,
Jul 02, 2023 Jul 02, 2023

Expressions don't have memory, so variables don't survive from one frame to the next, but you can calulate your x value based on the current time, like this:

var x = 0;
var y = 2;
var z = 10;

x += Math.floor(time/y);
x = Math.min(x,z);

or elapsed time since the layer's in point, like this:

var x = 0;
var y = 2;
var z = 10;

x += Math.floor((time-inPoint)/y);
x = Math.min(x,z);

 

Translate
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 ,
Jul 02, 2023 Jul 02, 2023
LATEST

Dan's idea to use floor to increase by 1 is very elegant. But I think your condition with the z must be implemented like this (since z should be a limit on the time, not on the final value, if I understand it correctly):

x = Math.floor(Math.min(time,z)/y);

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Translate
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