Skip to main content
Atte J.
Inspiring
July 28, 2025
Question

Comparing values in two different frames (expression?)

  • July 28, 2025
  • 1 reply
  • 152 views

Hello,

 

I need to compare values between 2 consecutive frames (in this case the Y position). How do I get that value in the previous frame?

 

Once I have that it's just if-else from there on.

1 reply

Atte J.
Atte J.Author
Inspiring
July 28, 2025

With a Google search I managed to put together this but it just gives me value 100 in every situation. VB is the variable for ValueBefore, VN means ValueNow...

 

VB = comp("Comp 1").layer("Red").transform.yPosition.valueAtTime(time - framesToTime(1));

VN = comp("Comp 1").layer("Red").transform.yPosition.valueAtTime;

if (VB <= VN) {T=0} else {T=100};

T

 

Dan Ebberts
Community Expert
Community Expert
July 28, 2025

You were close:

VB = comp("Comp 1").layer("Red").transform.yPosition.valueAtTime(time - framesToTime(1));
VN = comp("Comp 1").layer("Red").transform.yPosition.valueAtTime(time);
if (VB <= VN) {T = 0} else {T = 100};
T