ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Issue retrieving frame value (for loop involved)

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Eddy van der Leer
Issue retrieving frame value (for loop involved)
on Dec 13, 2018 at 11:14:06 pm

Hi,

I have an expression that sets the angle of a rotation, based on the value of a checkbox. If the checkbox value is 0, the angle is calculated one way, and if the checkbox is set to 1, the value is calculated using the delta in time between the current time and the time the checkbox value was last at 0 (i.e. one frame before the checkbox value changed).

The expression is working when the checkbox value is at 0, but once it is set to 1, the expression strangely only works for the first 6 frames after the checkbox value has changed. So looking at the code below, the deltaTime value goes 1, 2, 3, 4, 5, 6 and the next frame it goes to 0 and stays there.

Not sure if a screenshot is relevant here, but I can provide, if needed.

land = thisComp.layer("Animation").effect("Land")("Checkbox");
deltaTime = 0;
frame = thisComp.frameDuration;

if (land==0) {
ease(thisComp.layer("Animation").effect("Flap")("Slider"),-45,45,-15,15);
}
else {
for (i=0;i<time;i++) {
check = land.valueAtTime(time-(i*frame));
if (check==0) {
deltaTime = i;
break;
}
}
clamp(15-deltaTime,0,15);

}


Return to posts index

Dan Ebberts
Re: Issue retrieving frame value (for loop involved)
on Dec 14, 2018 at 12:05:01 am

I think this is your culprit:

for (i=0;i
i is counting frames, but time is in seconds.

I haven't tested it, but you could try changing time to timeToFrames(time).


Dan



Return to posts index

Eddy van der Leer
Re: Issue retrieving frame value (for loop involved)
on Dec 14, 2018 at 4:40:54 am

Hi Dan,

Thanks for replying, but I am using i as a multiplier with the frame duration, so all is converted into time.



Eddy


Return to posts index


Dan Ebberts
Re: Issue retrieving frame value (for loop involved)
on Dec 14, 2018 at 7:44:57 am

Did you try my suggestion?

Dan



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]