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

Adobe After Effects Expression

Community Beginner ,
Jul 02, 2023 Jul 02, 2023

Copy link to clipboard

Copied

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
Experiment , Expressions , Scripting

Views

395

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 , 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);

Votes

Translate

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

Copy link to clipboard

Copied

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);

 

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

Copy link to clipboard

Copied

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

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